dotfiles

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

commit 346e198781f27f8a1a5ef372c5d5bba4aaf32d47
parent b3b887643d3e133590f98d7fc3009bd8bab3bdc3
Author: Chris Noxz <chris@noxz.tech>
Date:   Sat, 22 Feb 2020 15:10:02 +0100

[bin] some minor changes to dmenu scripts

Diffstat:
Mbin/.bin/dmenu_confirm | 32+++++---------------------------
Dbin/.bin/dmenu_kill | 11-----------
Mbin/.bin/dmenu_layouts | 4+---
Mbin/.bin/dmenu_main | 49++++++++++++++++++++++++++-----------------------
Mbin/.bin/dmenu_power | 11-----------
Mbin/.bin/dmenu_vtc | 112++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---------------------
Abin/.bin/dmenu_vtc.bak | 52++++++++++++++++++++++++++++++++++++++++++++++++++++
7 files changed, 167 insertions(+), 104 deletions(-)

diff --git a/bin/.bin/dmenu_confirm b/bin/.bin/dmenu_confirm @@ -1,32 +1,10 @@ #!/bin/sh -args="" -cmd="" +[ -z "$1" ] && exit 1 +prompt="$1"; shift -while :; do - case "$1" in - -b | -f | -i) - args="$args $1" ;; - -l | -h | -m | -p | -fn | -nb | -nf | -sb | -sf ) - args="$args $1"; shift; args="$args $1";; - -w ) - args="$args $1"; shift; args="$args $(eval echo $1)" ;; - -cmd ) - shift; cmd="$1";; - --) - shift; break ;; - -*) - echo "invalid option: $1" 1>&2; exit 1 ;; - *) - break ;; - esac - shift -done - -if [ "$cmd" = "" ]; then +if [ "$(echo no\\nyes | dmenu_vtc $@ -p "$prompt")" = "yes" ]; then exit 0 -fi - -if [ "$(printf "no\nyes" | dmenu_vtc${args})" = "yes" ]; then - echo $cmd | ${SHELL:-"/bin/sh"} & +else + exit 1 fi diff --git a/bin/.bin/dmenu_kill b/bin/.bin/dmenu_kill @@ -1,11 +0,0 @@ -#!/bin/sh - -dmenu_confirm \ - -p "kill:" \ - -nb "#fb2222" \ - -nf "#000000" \ - -sb "#000000" \ - -sf "#fb2222" \ - -w "$(grep < ~/.data/dwm/dwm.log 'dwm: client:' \ - | tail -n 1 | cut -d ' ' -f 3)" \ - -cmd "echo kill client > /tmp/dwm.fifo" diff --git a/bin/.bin/dmenu_layouts b/bin/.bin/dmenu_layouts @@ -2,11 +2,9 @@ args=" -p layouts: -l 20" options=" - columns floating grid monocle - tcl tiled " @@ -15,6 +13,6 @@ layout="$(printf "$options" \ | sort \ | dmenu_vtc${args})" case "$layout" in - grid|columns|tiled|floating|monocle|tcl) + grid|tiled|floating|monocle) echo "set layout $layout" > "/tmp/dwm.fifo";; esac diff --git a/bin/.bin/dmenu_main b/bin/.bin/dmenu_main @@ -25,26 +25,29 @@ get_fm_key () { echo $(cat "$key_location") } -case "$(printf "$options" \ -| sed -e '/^$/d' -e 's/^[ \t]*//' \ -| sort \ -| dmenu_vtc${args})" in -bookmarks) - dmenu_bookmarks "$HOME/.data/bookmarks" ${args} -i -p bookmark:;; -radio) - dmenu_radio "$(get_fm_key)" ${args} -i -p provider:;; -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;; -esac +while :; do + case "$(printf "$options" \ + | sed -e '/^$/d' -e 's/^[ \t]*//' \ + | sort \ + | dmenu_vtc${args})" in + bookmarks) + dmenu_bookmarks "$HOME/.data/bookmarks" ${args} -i -p bookmark:;; + radio) + dmenu_radio "$(get_fm_key)" ${args} -i -p provider:;; + 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;; + *) break;; + esac +done diff --git a/bin/.bin/dmenu_power b/bin/.bin/dmenu_power @@ -8,17 +8,6 @@ options=" reboot " -if [ "$1" = "off" ]; then - dmenu_confirm \ - -p "shutdown:" \ - -nb "#fb2222" \ - -nf "#000000" \ - -sb "#000000" \ - -sf "#fb2222" \ - -cmd "sudo runit-init 0" - return 0; -fi - case "$(printf "$options" \ | sed -e '/^$/d' -e 's/^[ \t]*//' \ | sort \ diff --git a/bin/.bin/dmenu_vtc b/bin/.bin/dmenu_vtc @@ -1,39 +1,93 @@ #!/bin/sh # check if running in X -inx=$([ ! -z $XAUTHORITY ] && echo 1 || echo 0) +INX=$([ ! -z $XAUTHORITY ] && echo 1 || echo 0) -case $inx in +ARGNAME="" + +LUMI="$(readvtc 0 | lumi)" + +BOTTOM=false +PREGRAB=false +CASEINSENSITIVE=false + +VERTICALLINES="0" +HEIGHT="20" +MONITOR="" +PROMPT="" +FONT="dnoxz_numerics:pixelsize=12:autohint=false" +NFCOLOR="$(readvtc 6)" +NBCOLOR="$([ "$LUMI" -gt 50 ] && printf '#fdfdfd' || printf '#030303')" +SFCOLOR="$(readvtc 6)" +SBCOLOR="$(readvtc 5)" +WINDOW="" + +print_usage() { + echo "usage dmenu_vtc [-bfi] ..." +} + +handle_name() { + ARGNAME="" + case "$1" in + # flag arguments + -b) BOTTOM=true;; + -f) PREGRAB=true;; + -i) CASEINSSENSITIVE=true;; + # name/value arguments + -l | -h | -m | -p | -fn | -nb | -nf | -sb | -sf | -w) + ARGNAME="$1";; + esac +} + +handle_value() { + case "$ARGNAME" in + -l) VERTICALLINES="$1";; + -h) HEIGHT="$1";; + -m) MONITOR="$1";; + -p) PROMPT="$1";; + -fn) FONT="$1";; + -nf) NFCOLOR="$1";; + -nb) NBCOLOR="$1";; + -sf) SFCOLOR="$1";; + -sb) SBCOLOR="$1";; + -w) WINDOW="$1";; + --) break;; + -*) echo "invalid option: $ARGNAME" 1>&2; exit 1;; + *) break;; + esac + ARGNAME="" +} + +# read arguments +for var in "$@"; do + case "$var" in + --help) print_usage;; + -*) handle_name "$var";; + *) handle_value "$var";; + esac +done + +case $INX in 1) pgrep -x dmenu && exit - lumi="$(readvtc 0 | lumi)" - args=" - -fn "hack:size=9" \ - -nb $([ "$lumi" -gt 50 ] && printf '#fdfdfd' || printf '#030303') \ - -nf $(readvtc 6) \ - -sb $(readvtc 5) \ - -sf $(readvtc 6)" - - while :; do - case "$1" in - -b | -f | -i) - args="$args $1";; - -l | -h | -m | -p | -fn | -nb | -nf | -sb | -sf) - args="$args $1"; shift; args="$args $1";; - -w) - args="$args $1"; shift; args="$args $(eval echo $1)";; - --) - shift; break;; - -*) - echo "invalid option: $1" 1>&2; exit 1;; - *) - break;; - esac - shift - done - - dmenu${args} + ARGS=" \ + $([ "$BOTTOM" = true ] && echo "-b") \ + $([ "$PREGRAB" = true ] && echo "-f") \ + $([ "$CASEINSSENSITIVE" = true ] && echo "-i") \ + " + + dmenu $ARGS \ + -l "$VERTICALLINES" \ + -h "$HEIGHT" \ + -m "$MONITOR" \ + -p "$PROMPT" \ + -fn "$FONT" \ + -nf "$NFCOLOR" \ + -nb "$NBCOLOR" \ + -sf "$SFCOLOR" \ + -sb "$SBCOLOR" \ + -w "$WINDOW" ;; 0) # fix for 'cascading' fzfs diff --git a/bin/.bin/dmenu_vtc.bak b/bin/.bin/dmenu_vtc.bak @@ -0,0 +1,52 @@ +#!/bin/sh + +# check if running in X +inx=$([ ! -z $XAUTHORITY ] && echo 1 || echo 0) + +case $inx in +1) + pgrep -x dmenu && exit + + lumi="$(readvtc 0 | lumi)" + cmdline="" + args=" + -fn \"hack:size=9\" \ + -nb \"$([ "$lumi" -gt 50 ] && printf '#fdfdfd' || printf '#030303')\"\ + -nf \"$(readvtc 6)\" \ + -sb \"$(readvtc 5)\" \ + -sf \"$(readvtc 6)\"" + for arg in "$@" + do + cmdline="$cmdline $(echo $arg | sed 's/ /__SPC__/g')" + done + set -- $cmdline + while :; do + case "$1" in + -b | -f | -i) + args="$args $1";; + -l | -h | -m | -p | -fn | -nb | -nf | -sb | -sf) + args="$args $1"; shift; args="$args \"$1\"";; + -w) + args="$args $1"; shift; args="$args \"$(eval echo $1)\"";; + --) + shift; break;; + -*) + echo "invalid option: $1" 1>&2; exit 1;; + *) + break;; + esac + shift + done + + echo "echo '$(cat -)' | dmenu $(echo $args | sed 's/__SPC__/ /g')" | sh - +;; +0) + # fix for 'cascading' fzfs + sleep 0.01 + + fzf-tmux \ + --reverse \ + --select-1 \ + --exit-0 +;; +esac