dotfiles

My collection of dotfiles
git clone git://git.noxz.tech/dotfiles
Log | Files | Refs

commit f38fad0a32fc57db44e95ac22df8fbd18c177d75
parent c48759e7c8fcfa2fedfff1c386acd8df13206864
Author: Chris Noxz <chris@noxz.tech>
Date:   Fri, 13 Sep 2019 15:33:27 +0200

[bin] make dmenu scripts more readable

Diffstat:
Mbin/.bin/dmenu_layouts | 14++++++++++++--
Mbin/.bin/dmenu_main | 39++++++++++++++++++++++++++-------------
Mbin/.bin/dmenu_power | 24++++++++++++++++--------
Mbin/.bin/dmenu_url_open | 35+++++++++++++++++++++++------------
4 files changed, 77 insertions(+), 35 deletions(-)

diff --git a/bin/.bin/dmenu_layouts b/bin/.bin/dmenu_layouts @@ -1,9 +1,19 @@ #!/bin/sh args=" -p layouts: -l 20" -options="grid\ncolumns\ntiled\nfloating\nmonocle\ntcl" +options=" + columns + floating + grid + monocle + tcl + tiled +" -layout="$(printf "$options" | dmenu_vtc${args})" +layout="$(printf "$options" \ +| sed -e '/^$/d' -e 's/^[ \t]*//' \ +| sort \ +| dmenu_vtc${args})" case "$layout" in grid|columns|tiled|floating|monocle|tcl) echo "set layout $layout" > "/tmp/dwm.fifo";; diff --git a/bin/.bin/dmenu_main b/bin/.bin/dmenu_main @@ -1,37 +1,50 @@ #!/bin/sh args=" -p main: -l 20" -options="bookmarks\ndi.fm\ntodo\nsoundcloud\noperations\nyoutube\nman\npass\npower" +options=" + bookmarks + di.fm + man + operations + pass + power + soundcloud + todo + youtube +" get_fm_key () { local key_location="/tmp/.di.fm.key" local key_pass="di.fm/listen-key" - [ ! -f "$key_location" ] \ - && touch "$key_location" \ - && chmod 600 "$key_location" \ + [ ! -f "$key_location" ] \ + && touch "$key_location" \ + && chmod 600 "$key_location" \ && pass "$key_pass" > "$key_location" echo $(cat "$key_location") } -case "$(printf "$options" | sort | dmenu_vtc${args})" in -man) - dmenu_man${args} -i -p man:;; +case "$(printf "$options" \ +| sed -e '/^$/d' -e 's/^[ \t]*//' \ +| sort \ +| dmenu_vtc${args})" in bookmarks) dmenu_bookmarks "$HOME/.data/bookmarks" ${args} -i -p bookmark:;; di.fm) dmenu_di.fm "$(get_fm_key)" ${args} -i -p di.fm:;; -todo) - dmenu_todo "$HOME/.data/todo" ${args} -i -p todo:;; +man) + dmenu_man${args} -i -p man:;; +operations) + operations dmenu${args} -i -p operations:;; pass) dmenu_passmenu ${args} -i -p pass:;; +power) + dmenu_power${args} -i;; soundcloud) dmenu_sscw${args} -i;; +todo) + dmenu_todo "$HOME/.data/todo" ${args} -i -p todo:;; youtube) dmenu_yt_search${args} -i;; -power) - dmenu_power${args} -i;; -operations) - operations dmenu${args} -i -p operations:;; esac diff --git a/bin/.bin/dmenu_power b/bin/.bin/dmenu_power @@ -1,20 +1,28 @@ #!/bin/sh args=" -p power:" -options="lock\nlogout\nshutdown\nreboot" +options=" + lock + logout + shutdown + reboot +" if [ "$1" = "off" ]; then - dmenu_confirm \ - -p "shutdown:" \ - -nb "#fb2222" \ - -nf "#000000" \ - -sb "#000000" \ - -sf "#fb2222" \ + dmenu_confirm \ + -p "shutdown:" \ + -nb "#fb2222" \ + -nf "#000000" \ + -sb "#000000" \ + -sf "#fb2222" \ -cmd "sudo runit-init 0" return 0; fi -case "$(printf "$options" | dmenu_vtc${args})" in +case "$(printf "$options" \ +| sed -e '/^$/d' -e 's/^[ \t]*//' \ +| sort \ +| dmenu_vtc${args})" in lock) /usr/local/bin/slock -m "locked at $(date "+%H:%M:%S"; echo '------------------'; diff --git a/bin/.bin/dmenu_url_open b/bin/.bin/dmenu_url_open @@ -1,6 +1,14 @@ #!/bin/sh -options="copy\nmpv\nwget\nyt-dl\nsurf\nvimb\nw3m" +options=" + copy + mpv + surf + vimb + w3m + wget + yt-dl +" url="$1"; shift visual="$url" @@ -10,24 +18,27 @@ fi args=" $@ -i -p $visual" -case "$(printf "$options" | dmenu_vtc${args})" in +case "$(printf "$options" \ +| sed -e '/^$/d' -e 's/^[ \t]*//' \ +| sort \ +| dmenu_vtc${args})" in copy) - printf "$url" \ - | xclip -selection primary -f \ + printf "$url" \ + | xclip -selection primary -f \ | xclip -selection clipboard & ;; mpv) mpvc load "$url" ;; yt-dl-video) - youtube-dl \ - -f webm \ - -o "$HOME/downloads/%(title)s-%(id)s.%(ext)s" \ + youtube-dl \ + -f webm \ + -o "$HOME/downloads/%(title)s-%(id)s.%(ext)s" \ "$url" >/dev/null 2>&1 & ;; yt-dl-audio) - youtube-dl \ - -extract-audio \ - --audio-format vorbis \ - --audio-quality 0 \ - -o "$HOME/downloads/%(title)s-%(id)s.%(ext)s" \ + youtube-dl \ + -extract-audio \ + --audio-format vorbis \ + --audio-quality 0 \ + -o "$HOME/downloads/%(title)s-%(id)s.%(ext)s" \ "$url" >/dev/null 2>&1 & ;; wget) wget "$url" >/dev/null 2>&1 & ;;