diff options
author | Von Random <von@vdrandom.org> | 2020-02-11 15:10:03 +0300 |
---|---|---|
committer | Von Random <von@vdrandom.org> | 2020-02-11 15:10:03 +0300 |
commit | 8e5f4e4d9ec6b5eccf16b61e8ea90bc8de93c4f0 (patch) | |
tree | 2cab2a9dff93dae902d790bc53820dd5925a8e27 | |
parent | 2fb479e4ec2db62fca2723080dc30ebe914841ab (diff) |
various tweaks and refactors
-rwxr-xr-x | dmenu_multicmd | 19 | ||||
-rwxr-xr-x | dmenu_pass | 2 | ||||
-rwxr-xr-x | noisegen | 2 | ||||
-rwxr-xr-x | termcompat | 1 | ||||
-rwxr-xr-x | tvim | 4 | ||||
-rwxr-xr-x | vimwiki | 5 | ||||
-rwxr-xr-x | xscreensaver-companion | 22 |
7 files changed, 31 insertions, 24 deletions
diff --git a/dmenu_multicmd b/dmenu_multicmd index 95b425f..2c25293 100755 --- a/dmenu_multicmd +++ b/dmenu_multicmd @@ -20,7 +20,6 @@ import subprocess import sys import yaml - def run_cmd(cmd, stdin=subprocess.PIPE, data=None): proc = subprocess.Popen( cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=stdin @@ -35,24 +34,22 @@ def run_cmd(cmd, stdin=subprocess.PIPE, data=None): sys.stderr.write('\n'.join(err_msg) + '\n') return stdout - -def run_multicmd(cmds): - for cmd in cmds: - run_cmd(cmd) - - def main(): config_path = sys.argv[1] with open(config_path, mode='r') as config: - conf = yaml.load(config.read()) + conf = yaml.safe_load(config.read()) dmenu_cmd = ['/usr/bin/dmenu', '-p', conf.get('name', 'N/A')] + sys.argv[2:] dmenu_opt = '\n'.join(conf['multicmd']).encode() selection = run_cmd(dmenu_cmd, data=dmenu_opt).decode('UTF-8') + #selection = sys.argv[2] if not selection in conf['multicmd']: sys.exit(1) - run_multicmd(conf.get('cmd_pre', tuple())) - run_multicmd(conf['multicmd'][selection]) - run_multicmd(conf.get('cmd_post', tuple())) + cmds =\ + conf.get('cmd_pre', list()) +\ + conf['multicmd'][selection] +\ + conf.get('cmd_post', list()) + for cmd in cmds: + run_cmd(cmd) if __name__ == '__main__': main() @@ -28,5 +28,5 @@ if [[ $typeit -eq 0 ]]; then fi notify-send -a "pass" "$msg" "$password" else - pass show "$password" | { read -r pass; printf %s "$pass"; } | xdotool type --clearmodifiers --file - + gopass show "$password" | { read -r pass; printf %s "$pass"; } | xdotool type --clearmodifiers --file - fi @@ -7,4 +7,4 @@ case $1 in *) printf "%s is a wrong noise type\n" $1 >&2 ; exit 1 ;; esac -play -n synth $noise_type +exec play -n synth $noise_type @@ -1,6 +1,7 @@ #!/usr/bin/env bash # run with more compatible TERM value typeset -A terms=( + [xterm-kitty]='xterm' [rxvt-unicode-256color]='rxvt-unicode' [st-256color]='xterm-256color' [tmux-256color]='screen.xterm-new' @@ -9,6 +9,6 @@ error() { } termbin=$(command -v default-terminal-emulator) || termbin=$(command -v xterm) || error "No terminal found!" -vimbin=$(command -v vim) || error "No vim binary found!" +vimbin=$(command -v nvim) || vimbin=$(command -v vim) || vimbin=$(command -v vi) || error "No vim binary found!" -exec "$termbin" -c tvim -e "$vimbin" "${vimopt[@]}" "$@" &>/dev/null & disown +exec "$termbin" -e "$vimbin" "${vimopt[@]}" "$@" &>/dev/null & disown @@ -1,11 +1,8 @@ #!/usr/bin/zsh INDEX="$HOME/vimwiki/index.md" -WIKIOPTS="[{'path': '$HOME/vimwiki/', 'syntax': 'markdown', 'ext': '.md'}]" VIMOPTS=( '-c' 'set titlestring=vimwiki' - '-c' "let g:vimwiki_list = $WIKIOPTS" - '-c' 'packadd vimwiki' - '-c' "e $INDEX" + '-c' 'VimwikiIndex' ) case $1 in diff --git a/xscreensaver-companion b/xscreensaver-companion index 799e098..929f48a 100755 --- a/xscreensaver-companion +++ b/xscreensaver-companion @@ -3,6 +3,17 @@ pidfile=${XDG_RUNTIME_DIR-/run/user/$UID}/xscreensaver-companion.pid trap "rm -f $pidfile" INT KILL +function check_start +{ + # check if the service is running and, if not, start it in the background + # and detach + if pgrep -u $USER $1 >/dev/null; then + return 0 + else + $* &>/dev/null </dev/null & disown + fi +} + function init_pidfile { local pid @@ -23,17 +34,18 @@ function parse_actions while read action _; do case $action in (LOCK|BLANK) - /usr/bin/setxkbmap us -option - /usr/bin/numlockx off - /usr/bin/notify-send DUNST_COMMAND_PAUSE + setxkbmap us -option + notify-send DUNST_COMMAND_PAUSE ;; (UNBLANK) + check_start gxkb $HOME/git/mine/vscripts/mykblayouts - /usr/bin/notify-send DUNST_COMMAND_RESUME + $HOME/.local/bin/touchpad-config + notify-send DUNST_COMMAND_RESUME ;; esac done } init_pidfile -/usr/bin/xscreensaver-command -watch | parse_actions +xscreensaver-command -watch | parse_actions |