diff --git a/README.md b/README.md index 8886615..763d412 100644 --- a/README.md +++ b/README.md @@ -40,16 +40,15 @@ the source code for more details. most functionality is accessible from launch and action only ### Notes -* The download action uses youtube-dl to download whatever is in the keyboard - to ~/Downloads/tmp -* You may want to bind Mod4+a to `launch action` and Mod4+g to `prompt launch` -* Some prompts like `search package` will infer with their default operation +- The download action uses youtube-dl to download whatever is in the keyboard +- to ~/Downloads/tmp +- You may want to bind Mod4+a to `launch action` and Mod4+g to `prompt launch` +- Some prompts like `search package` will infer with their default operation when the string entered is an invalid selection ## mru -Used for storing file paths and their modification times in ~/.cache/mru. It -doesn't actually implement a caching algorithm using hit rate but it may be -added in the future. +Used for storing file paths and their modification times in ~/.cache/mru/. +When a file is opened with prompt open, it moves to the top of the home list mru [COMMAND] [CACHE] #### COMMMAND @@ -60,16 +59,23 @@ added in the future. - insert [ FILE ] #### Notes +- by default, it ignores hidden directories - If no cache is specified, it assumes 'home' -- If if the file passed to insert does not exist, it is removed from the cache +- more cache pathes can be added by editing the cache_info variable in the + source code. For last load times you may want to seperate different tasks or + types of files into their own cache, i.e projects, videos, config files. +- If if the file passed to `mru insert` does not exist, it is removed from the cache +- You may want to run mru update at startup to add new files and cleanup hidden + files in .cache/mru ### Initializing - mru init; mru create home $HOME all + mru init ## pages pages is a command for viewing /tmp/pages-{number} files with less or zathura. -The files are the result of prompt commands like `prompt action` -> Go page or -can be created from your own tools. I use it for viewing documentation. +The files are the result of prompt commands like `prompt search` -> Go page or +can be created from your own tools. I use it for viewing local documentation +quickly. ### Usage pages [ pager | pdf | browser | send ] [ NAME ] @@ -83,9 +89,6 @@ exists. use to convert a markdown file to html and open it in a browser: `:!markdown % | pages send 1.html | pages browser 1.html` This could then be given it's own keybinding. -Use it to automagically select and run terminal applications, send signals to -daemons, execute arbitrary commands, search the web, grab passwords from the -password manager, and more. #### TODO - Finish vpn and networking stuff after ini script is finished, then make sure diff --git a/dwm-statusbar b/dwm-statusbar index b037ec5..0fc2602 100755 --- a/dwm-statusbar +++ b/dwm-statusbar @@ -9,7 +9,7 @@ brightness_symbol=🔅 while true; do volume=$(amixer sget Master | awk -F"[][]" 'END{ print $2 }') volume_amount=$(printf $volume | tr -d %) - if [ $volume_amount == 0 ]; then + if [ $volume_amount = 0 ]; then volume_symbol=$speaker_muted elif [ $volume_amount -lt 30 ]; then volume_symbol=$speaker_low diff --git a/mru b/mru index a4b45d7..bb4dfee 100755 --- a/mru +++ b/mru @@ -1,22 +1,14 @@ #!/bin/sh #To add more caches, add a newline to this string and follow the existing name:path format +#Edit create_new to change find behaviour cache_info="home:$HOME" HOME=/home/immanuel XDG_CACHE_HOME="$HOME/.cache" init() { mkdir -p $XDG_CACHE_HOME/mru - file=$XDG_CACHE_HOME/mru/"$1" - if [ -z "$1" ]; then file="$file""home"; fi - path=$(printf $cache_info | grep "^$1" - | cut -d: -f2) - - if [ -z "$path" -o ! -e "$path" ]; then - printf "path:$path from cache:$file does not exist\n" 1>&2; exit; - fi - find $path -type f -not \( -path '*/.*/*' -o -path '*node_modules/*' -o \ - -path '*Backups/my-plugins*' -o -path '*.sw[po]' \) -printf \ - '%TY-%Tm-%Td\t%TT\t%p\n' | sort -r > $file'.new' + create_new "$1" mv "$file.new" "$file" } @@ -27,22 +19,21 @@ get_cache_path() { printf "$path" } -update() { - clean +create_new() { file=$XDG_CACHE_HOME/mru/"$1" - if [ -z "$1" ]; then file="$file""home"; fi - path=$(printf $cache_info | grep "^$1" - | cut -d: -f2) + path=$(get_cache_path "$1") - if [ -z "$path" -o ! -e "$path" ]; then - printf "path:$path from cache:$file does not exist\n"; exit; + find $path -type f -not \( -path '*/.*/*' -o -path '*node_modules/*' -o \ + -path '*Backups/my-plugins*' -o -path '*.sw[po]' \) -printf \ + '%TY-%Tm-%Td\t%TT\t%p\n' | sort -r > $file'.new' +} +update() { + clean + name="$1" + if [ -z "$1" ]; then + name='home' fi - #init a temporary file. The traverse the original, if a file exists in a - # but not in b, delete it from a, if it exists in a and b delete it from b. - # append the rest of b to a. - # This should check if each file found is already there. If not, add it to it's position based on modified time - # find $path -type f -not \( -path '*/.*/*' -o -path '*node_modules/*' -o \ - # -path '*Backups/my-plugins*' -o -path '*.sw[po]' \) -printf \ - # '%TY-%Tm-%Td\t%TT\t%p\n' | sort -r > $file + create_new "$name" } output() { diff --git a/prompt b/prompt index f173434..0b4cf6f 100755 --- a/prompt +++ b/prompt @@ -55,6 +55,7 @@ action() { Play Music Command Command to clipboard + Choose Select VPN Disable VPN Enable VPN @@ -77,6 +78,7 @@ action() { 'Disable Bar') tmux set -g status off;; 'Enable Bar') tmux set -g status on;; 'Command') cmd;; + 'Choose') chooser;; 'Command to clipboard') cmd_clip;; 'Username') username;; 'Password') password;; @@ -129,7 +131,7 @@ editor() { } opener() { - mru list | dmenu -i -l 20 -p 'open' | while read f; do xdg-open $f; done + mru list | dmenu -i -l 20 -p 'open' | while read f; do mru insert "$f" &; xdg-open $f; done } screenshot() { @@ -298,6 +300,14 @@ edit_password() { if [ -n "$error" ]; then notify-send -u low -t 3000 "password edit error" "$error"; fi } +chooser() { + f=$(mru list | dmenu -i -l 20 -p 'choose file') + if [ -z "$f" ]; then exit; fi + c=$(dmenu_path | dmenu -i -p 'operation') + if [ -z $c ]; then exit; fi + $c "$f" +} + case $1 in launch) launch;; action) action;; @@ -309,5 +319,6 @@ case $1 in edit_password) edit_password;; search) do_search;; open) opener;; + choose) chooser;; *) printf "Invalid argument";; esac