Переглянути джерело

various tweaks and refactors

master
Von Random 9 місяці тому
джерело
коміт
8e5f4e4d9e
7 змінених файлів з 31 додано та 24 видалено
  1. +8
    -11
      dmenu_multicmd
  2. +1
    -1
      dmenu_pass
  3. +1
    -1
      noisegen
  4. +1
    -0
      termcompat
  5. +2
    -2
      tvim
  6. +1
    -4
      vimwiki
  7. +17
    -5
      xscreensaver-companion

+ 8
- 11
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()

+ 1
- 1
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

+ 1
- 1
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

+ 1
- 0
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'


+ 2
- 2
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

+ 1
- 4
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


+ 17
- 5
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

Завантаження…
Відмінити
Зберегти