summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVon Random <von@vdrandom.org>2020-02-11 15:10:03 +0300
committerVon Random <von@vdrandom.org>2020-02-11 15:10:03 +0300
commit8e5f4e4d9ec6b5eccf16b61e8ea90bc8de93c4f0 (patch)
tree2cab2a9dff93dae902d790bc53820dd5925a8e27
parent2fb479e4ec2db62fca2723080dc30ebe914841ab (diff)
various tweaks and refactors
-rwxr-xr-xdmenu_multicmd19
-rwxr-xr-xdmenu_pass2
-rwxr-xr-xnoisegen2
-rwxr-xr-xtermcompat1
-rwxr-xr-xtvim4
-rwxr-xr-xvimwiki5
-rwxr-xr-xxscreensaver-companion22
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()
diff --git a/dmenu_pass b/dmenu_pass
index 72d5f91..8fdd95f 100755
--- a/dmenu_pass
+++ b/dmenu_pass
@@ -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
diff --git a/noisegen b/noisegen
index fe3415a..8b634cc 100755
--- a/noisegen
+++ b/noisegen
@@ -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
diff --git a/termcompat b/termcompat
index eebd93d..0681c66 100755
--- a/termcompat
+++ b/termcompat
@@ -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'
diff --git a/tvim b/tvim
index 509804c..63f5b16 100755
--- a/tvim
+++ b/tvim
@@ -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
diff --git a/vimwiki b/vimwiki
index 931d709..5b1baa5 100755
--- a/vimwiki
+++ b/vimwiki
@@ -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