@@ -40,16 +40,15 @@ the source code for more details. | |||||
most functionality is accessible from launch and action only | most functionality is accessible from launch and action only | ||||
### Notes | ### 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 | when the string entered is an invalid selection | ||||
## mru | ## 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] | mru [COMMAND] [CACHE] | ||||
#### COMMMAND | #### COMMMAND | ||||
@@ -60,16 +59,23 @@ added in the future. | |||||
- insert [ FILE ] | - insert [ FILE ] | ||||
#### Notes | #### Notes | ||||
- by default, it ignores hidden directories | |||||
- If no cache is specified, it assumes 'home' | - 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 | ### Initializing | ||||
mru init; mru create home $HOME all | |||||
mru init | |||||
## pages | ## pages | ||||
pages is a command for viewing /tmp/pages-{number} files with less or zathura. | 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 | ### Usage | ||||
pages [ pager | pdf | browser | send ] [ NAME ] | 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 | 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 | % | pages send 1.html | pages browser 1.html` This could then be given it's | ||||
own keybinding. | 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 | #### TODO | ||||
- Finish vpn and networking stuff after ini script is finished, then make sure | - Finish vpn and networking stuff after ini script is finished, then make sure | ||||
@@ -9,7 +9,7 @@ brightness_symbol=🔅 | |||||
while true; do | while true; do | ||||
volume=$(amixer sget Master | awk -F"[][]" 'END{ print $2 }') | volume=$(amixer sget Master | awk -F"[][]" 'END{ print $2 }') | ||||
volume_amount=$(printf $volume | tr -d %) | volume_amount=$(printf $volume | tr -d %) | ||||
if [ $volume_amount == 0 ]; then | |||||
if [ $volume_amount = 0 ]; then | |||||
volume_symbol=$speaker_muted | volume_symbol=$speaker_muted | ||||
elif [ $volume_amount -lt 30 ]; then | elif [ $volume_amount -lt 30 ]; then | ||||
volume_symbol=$speaker_low | volume_symbol=$speaker_low | ||||
@@ -1,22 +1,14 @@ | |||||
#!/bin/sh | #!/bin/sh | ||||
#To add more caches, add a newline to this string and follow the existing name:path format | #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" | cache_info="home:$HOME" | ||||
HOME=/home/immanuel | HOME=/home/immanuel | ||||
XDG_CACHE_HOME="$HOME/.cache" | XDG_CACHE_HOME="$HOME/.cache" | ||||
init() { | init() { | ||||
mkdir -p $XDG_CACHE_HOME/mru | 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" | mv "$file.new" "$file" | ||||
} | } | ||||
@@ -27,22 +19,21 @@ get_cache_path() { | |||||
printf "$path" | printf "$path" | ||||
} | } | ||||
update() { | |||||
clean | |||||
create_new() { | |||||
file=$XDG_CACHE_HOME/mru/"$1" | 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 | 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() { | output() { | ||||
@@ -55,6 +55,7 @@ action() { | |||||
Play Music | Play Music | ||||
Command | Command | ||||
Command to clipboard | Command to clipboard | ||||
Choose | |||||
Select VPN | Select VPN | ||||
Disable VPN | Disable VPN | ||||
Enable VPN | Enable VPN | ||||
@@ -77,6 +78,7 @@ action() { | |||||
'Disable Bar') tmux set -g status off;; | 'Disable Bar') tmux set -g status off;; | ||||
'Enable Bar') tmux set -g status on;; | 'Enable Bar') tmux set -g status on;; | ||||
'Command') cmd;; | 'Command') cmd;; | ||||
'Choose') chooser;; | |||||
'Command to clipboard') cmd_clip;; | 'Command to clipboard') cmd_clip;; | ||||
'Username') username;; | 'Username') username;; | ||||
'Password') password;; | 'Password') password;; | ||||
@@ -129,7 +131,7 @@ editor() { | |||||
} | } | ||||
opener() { | 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() { | screenshot() { | ||||
@@ -298,6 +300,14 @@ edit_password() { | |||||
if [ -n "$error" ]; then notify-send -u low -t 3000 "password edit error" "$error"; fi | 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 | case $1 in | ||||
launch) launch;; | launch) launch;; | ||||
action) action;; | action) action;; | ||||
@@ -309,5 +319,6 @@ case $1 in | |||||
edit_password) edit_password;; | edit_password) edit_password;; | ||||
search) do_search;; | search) do_search;; | ||||
open) opener;; | open) opener;; | ||||
choose) chooser;; | |||||
*) printf "Invalid argument";; | *) printf "Invalid argument";; | ||||
esac | esac |