From 9d76b5b44a8eff29c036e65f4f28a82fe3835ad7 Mon Sep 17 00:00:00 2001 From: zachir Date: Sun, 22 Jan 2023 13:16:21 -0600 Subject: move scripts to /bin/sh (not /sbin/sh) and add some wayland helpers --- README.md | 12 ------------ browser | 2 +- bsc | 2 +- bspt | 2 +- crcparse | 2 +- dmpv | 2 +- fdc | 2 +- ffc | 2 +- gen_waybar_confs.sh | 10 ++++++++++ gettags | 2 +- herbsttags | 2 +- hwinmv | 2 +- launch_waybar.sh | 11 +++++++++++ liberclip | 2 +- lwc | 2 +- maim_active | 2 +- monattach | 2 +- mondetach | 2 +- mpdup | 2 +- mprisctl | 2 +- notify-fw | 2 +- qbc | 2 +- river_sp | 5 +++++ sigdwmb | 2 +- slockd | 2 +- songgrab | 2 +- startvm | 2 +- startxw | 4 ++-- svlogc | 2 +- swayidlechk | 2 +- swayidletog | 2 +- tagimg | 2 +- tagmp3 | 2 +- todo | 2 +- toggle | 2 +- toggletouchpad | 2 +- tsoff | 2 +- tson | 2 +- waytoggle | 2 +- xidlechk | 2 +- xidletog | 2 +- 41 files changed, 64 insertions(+), 50 deletions(-) create mode 100755 gen_waybar_confs.sh create mode 100755 launch_waybar.sh create mode 100644 river_sp diff --git a/README.md b/README.md index b428931..a01572b 100644 --- a/README.md +++ b/README.md @@ -17,18 +17,6 @@ accept them. ## Scripts -### barmenu - -`barmenu` is a script to call either dmenu or bemenu, depending on if Wayland or -X is running. If X is running (`$WAYLAND_DISPLAY` is unset and `$DISPLAY` is), -the script will run dmenu with the provided args. Otherwise, it will run bemenu -with the provided args (albeit replacing -h with -H). - -### barmenu_run - -`barmenu_run` is a script to replace both dmenu_run and bemenu-run, to call -barmenu instead. - ### battery `battery` is a 'block' for dwmblocks to check the status of the battery, using diff --git a/browser b/browser index 7e8083d..4ac15cc 100755 --- a/browser +++ b/browser @@ -1,4 +1,4 @@ -#!/sbin/sh +#!/bin/sh [ -z "$BROWSER" ] && BROWSER="qbc" BROWSERS="qbc fdc diff --git a/bsc b/bsc index b0e5409..148ac48 100755 --- a/bsc +++ b/bsc @@ -1,4 +1,4 @@ -#!/sbin/sh +#!/bin/sh PROFILES=`grep 'Path=' ~/.moonchild\ productions/basilisk/profiles.ini | cut -d'.' -f2` CHOSEN=`echo "$PROFILES" | barmenu -l 15` [ -z "$CHOSEN" ] && exit 2 diff --git a/bspt b/bspt index 8fed85a..541d525 100755 --- a/bspt +++ b/bspt @@ -1,4 +1,4 @@ -#!/sbin/sh +#!/bin/sh get_cmd () { echo "$@" | sed "s/"$1" //" diff --git a/crcparse b/crcparse index ee823b1..fda41dd 100755 --- a/crcparse +++ b/crcparse @@ -1,4 +1,4 @@ -#!/sbin/sh +#!/bin/sh if [ -n "$XDG_CONFIG_HOME" ]; then CONPATH="$XDG_CONFIG_HOME" diff --git a/dmpv b/dmpv index f5742f5..c956773 100755 --- a/dmpv +++ b/dmpv @@ -1,4 +1,4 @@ -#!/sbin/sh +#!/bin/sh cd ~/Videos case "$@" in diff --git a/fdc b/fdc index d7bc680..39773d6 100755 --- a/fdc +++ b/fdc @@ -1,4 +1,4 @@ -#!/sbin/sh +#!/bin/sh PROFILES=`grep 'Path=' ~/.firedragon/profiles.ini | cut -d'.' -f2` CHOSEN=`echo "$PROFILES" | barmenu -l 15` [ -z "$CHOSEN" ] && exit 2 diff --git a/ffc b/ffc index 6fd8e68..7c7e03b 100755 --- a/ffc +++ b/ffc @@ -1,4 +1,4 @@ -#!/sbin/sh +#!/bin/sh PROFILES=`grep 'Path=' ~/.mozilla/firefox/profiles.ini | cut -d'.' -f2` CHOSEN=`echo "$PROFILES" | barmenu -l 15` [ -z "$CHOSEN" ] && exit 2 diff --git a/gen_waybar_confs.sh b/gen_waybar_confs.sh new file mode 100755 index 0000000..36befae --- /dev/null +++ b/gen_waybar_confs.sh @@ -0,0 +1,10 @@ +#!/bin/sh + +WCLONG="$(crcparse WC)" +WC="$(basename "$WCLONG")" + +OUTPUTS="$(wlr-randr | grep -B2 'Enabled: yes' | sed '/^\s\s*/d;/^--/d' | cut -d' ' -f1)" + +echo "$OUTPUTS" | while read i; do + sed 's/%%DISPLAY%%/'$i'/' "$XDG_CONFIG_HOME"/waybar/config-$WC > "$XDG_CONFIG_HOME"/waybar/config-$WC-$i +done diff --git a/gettags b/gettags index fc7ab88..b2612be 100755 --- a/gettags +++ b/gettags @@ -1,4 +1,4 @@ -#!/sbin/sh +#!/bin/sh case "$(echo "$1" | rev | cut -d'.' -f1 | rev)" in "mp3") mid3v2 -l "$1" | awk 'xor(/^TPE1/,/^TALB/) {printf (NR%2==0) ? $0 "\n" : $0 "|"}' | sed 's/TPE1=//;s/TALB=//' ;; diff --git a/herbsttags b/herbsttags index 0e48804..97b9ce4 100755 --- a/herbsttags +++ b/herbsttags @@ -1,3 +1,3 @@ -#!/sbin/sh +#!/bin/sh herbstclient tag_status | sed 's/^\s//;s/#/%{u#00ffff}%{+u} /;s/\:/%{u#0000ff}%{+u} /g;s/\!/%{u#00ff00}%{+u} /g;s/\./%{u#ffffff} /g;s/\t/ %{-u}/g' diff --git a/hwinmv b/hwinmv index fa70d80..e71215c 100755 --- a/hwinmv +++ b/hwinmv @@ -1,3 +1,3 @@ -#!/sbin/sh +#!/bin/sh herbstclient "$1" "$2" && polybar-msg hook herbstluftwm 1 diff --git a/launch_waybar.sh b/launch_waybar.sh new file mode 100755 index 0000000..1803ada --- /dev/null +++ b/launch_waybar.sh @@ -0,0 +1,11 @@ +#!/bin/sh + +killall waybar + +if type "wlr-randr"; then + for m in $(wlr-randr | grep -B2 'Enabled: yes' | sed '/^\s\s*/d;/^--$/d' | cut -d' ' -f1); do + waybar -c "$XDG_CONFIG_HOME"/waybar/config-$1-$m & + done +else + waybar +fi diff --git a/liberclip b/liberclip index 27d839d..5af8ae5 100755 --- a/liberclip +++ b/liberclip @@ -1,4 +1,4 @@ -#!/sbin/sh +#!/bin/sh xclip -selection clipboard -o | \ sed -e 's/www.youtube.com/yewtu.be/;s/youtu.be/yewtu.be/' \ diff --git a/lwc b/lwc index 819861a..0fe2479 100755 --- a/lwc +++ b/lwc @@ -1,4 +1,4 @@ -#!/sbin/sh +#!/bin/sh PROFILES=`grep 'Path=' ~/.librewolf/profiles.ini | cut -d'.' -f2` CHOSEN=`echo "$PROFILES" | barmenu -l 15` [ -z "$CHOSEN" ] && exit 2 diff --git a/maim_active b/maim_active index e742c2c..2601aed 100755 --- a/maim_active +++ b/maim_active @@ -1,4 +1,4 @@ #!/bin/sh -FNAME="$(echo "" | dmenu -p 'filename: ')" +FNAME="$(echo "" | barmenu -p 'filename: ')" maim -i $(xdotool getactivewindow) "$FNAME" diff --git a/monattach b/monattach index 9eef6b6..948974b 100755 --- a/monattach +++ b/monattach @@ -1,4 +1,4 @@ -#!/sbin/sh +#!/bin/sh XSTATS="$(xrandr)" diff --git a/mondetach b/mondetach index 47d7d6a..c7f8998 100755 --- a/mondetach +++ b/mondetach @@ -1,4 +1,4 @@ -#!/sbin/sh +#!/bin/sh XSTATS="$(xrandr)" diff --git a/mpdup b/mpdup index ca56b4a..434c0fb 100755 --- a/mpdup +++ b/mpdup @@ -1,4 +1,4 @@ -#!/sbin/sh +#!/bin/sh # This loop will update the mpd statusbar module whenever a command changes the # music player's status. mpd must be running on X's start for this to work. diff --git a/mprisctl b/mprisctl index 6ea7745..9577ead 100755 --- a/mprisctl +++ b/mprisctl @@ -1,4 +1,4 @@ -#!/sbin/sh +#!/bin/sh DMENU_PROMPT=$(playerctl -l | barmenu -p 'Players:') [ -z "$DMENU_PROMPT" ] && exit 1 diff --git a/notify-fw b/notify-fw index bce7938..55bfde8 100755 --- a/notify-fw +++ b/notify-fw @@ -1,4 +1,4 @@ -#!/sbin/sh +#!/bin/sh LIST="$(doas iptables -S)" LIST6="$(doas ip6tables -S)" diff --git a/qbc b/qbc index d44d0c0..2bd3b6d 100755 --- a/qbc +++ b/qbc @@ -1,4 +1,4 @@ -#!/sbin/sh +#!/bin/sh SESSIONS=`qbpm list` [ -z "$SESSIONS" ] && qutebrowser $@ diff --git a/river_sp b/river_sp new file mode 100644 index 0000000..198aaac --- /dev/null +++ b/river_sp @@ -0,0 +1,5 @@ +#!/bin/sh + +scratch_tag=$((1 << 9)) + +riverctl map normal Alt Z toggle-focused-tags ${scratch_tag} diff --git a/sigdwmb b/sigdwmb index b5942b0..b21a991 100755 --- a/sigdwmb +++ b/sigdwmb @@ -1,4 +1,4 @@ -#!/sbin/sh +#!/bin/sh BLOCKS=`grep '^\s*{"' ~/.local/src/dwmblocks/config.h | cut -d'"' -f4 | uniq` for i in $@; do if `echo "$BLOCKS" | grep "$i" >/dev/null`; then diff --git a/slockd b/slockd index 2c31320..55fc66a 100755 --- a/slockd +++ b/slockd @@ -1,4 +1,4 @@ -#!/sbin/sh +#!/bin/sh if [ -z "$WAYLAND_DISPLAY" ]; then LOCKER=slock diff --git a/songgrab b/songgrab index 808ecb4..879baac 100755 --- a/songgrab +++ b/songgrab @@ -1,4 +1,4 @@ -#!/sbin/sh +#!/bin/sh # check flags for i in $@; do diff --git a/startvm b/startvm index 482bfbb..4a7b3ee 100755 --- a/startvm +++ b/startvm @@ -1,4 +1,4 @@ -#!/sbin/sh +#!/bin/sh SERVICES="libvirtd virtlockd virtlogd" doas rsm start $SERVICES virt-manager --no-fork && doas rsm stop $SERVICES diff --git a/startxw b/startxw index 1782c1d..9b947f0 100755 --- a/startxw +++ b/startxw @@ -1,11 +1,11 @@ -#!/sbin/sh +#!/bin/sh if [ `crcparse wayland` = "y" ]; then case `crcparse WC` in `which dwl`) exec `which dwl` > ~/.cache/dwltags ;; - "*") + *) exec `crcparse WC` ;; esac else diff --git a/svlogc b/svlogc index 7b77a67..1df3a59 100755 --- a/svlogc +++ b/svlogc @@ -1,4 +1,4 @@ -#!/sbin/sh +#!/bin/sh SERV_NAME=$(echo "$1" | sed 's/\/log$//') [ -f /var/log/"$SERV_NAME"/current ] && tac /var/log/"$(echo "$1" | sed 's/\/log$//')"/current | less || echo "Cannot read log" diff --git a/swayidlechk b/swayidlechk index 60322b9..8717360 100755 --- a/swayidlechk +++ b/swayidlechk @@ -1,3 +1,3 @@ -#!/sbin/sh +#!/bin/sh [ $(pidof swayidle) ] && echo "🌑" || echo "🌕" diff --git a/swayidletog b/swayidletog index 42510ac..27d9db8 100755 --- a/swayidletog +++ b/swayidletog @@ -1,4 +1,4 @@ -#!/sbin/sh +#!/bin/sh SWIDLE=$(pidof swayidle) if [ ! -z "$SWIDLE" ] ; then diff --git a/tagimg b/tagimg index 10017a2..109e7bd 100755 --- a/tagimg +++ b/tagimg @@ -1,4 +1,4 @@ -#!/sbin/sh +#!/bin/sh # check for flags for i in $@; do diff --git a/tagmp3 b/tagmp3 index baed43f..c6bfe4f 100755 --- a/tagmp3 +++ b/tagmp3 @@ -1,4 +1,4 @@ -#!/sbin/sh +#!/bin/sh FILENAME=`echo $@ | rev | cut -d' ' -f1 | rev` diff --git a/todo b/todo index e90965f..62bee0a 100755 --- a/todo +++ b/todo @@ -1,3 +1,3 @@ -#!/sbin/sh +#!/bin/sh "${EDITOR:-nvim}" ~/todo.txt diff --git a/toggle b/toggle index 28dda1e..aca0a47 100755 --- a/toggle +++ b/toggle @@ -1,4 +1,4 @@ -#!/sbin/sh +#!/bin/sh if type disown >/dev/null; then killall $1 ; $@ >/dev/null & disown diff --git a/toggletouchpad b/toggletouchpad index 553cf60..b10d10d 100755 --- a/toggletouchpad +++ b/toggletouchpad @@ -1,4 +1,4 @@ -#!/sbin/sh +#!/bin/sh CONTROLLER=`which synclient` [ -x "$CONTROLLER" ] && SYNCLIENT=y || CONTROLLER=`which xinput` [ ! -x "$CONTROLLER" ] && XINPUT=y || echo "This script requires X11" diff --git a/tsoff b/tsoff index bf9291d..89372ef 100755 --- a/tsoff +++ b/tsoff @@ -1,4 +1,4 @@ -#!/sbin/sh +#!/bin/sh if [ -n "$XDG_CONFIG_HOME" ]; then CONPATH="$XDG_CONFIG_HOME" diff --git a/tson b/tson index c8d137b..aa7cc9f 100755 --- a/tson +++ b/tson @@ -1,4 +1,4 @@ -#!/sbin/sh +#!/bin/sh if [ -n "$XDG_CONFIG_HOME" ]; then CONPATH="$XDG_CONFIG_HOME" diff --git a/waytoggle b/waytoggle index 8da651d..711aa8b 100755 --- a/waytoggle +++ b/waytoggle @@ -1,4 +1,4 @@ -#!/sbin/sh +#!/bin/sh if [ -n "$(pgrep -x waybar)" ]; then pkill waybar diff --git a/xidlechk b/xidlechk index 7611f89..980ab02 100755 --- a/xidlechk +++ b/xidlechk @@ -1,4 +1,4 @@ -#!/sbin/sh +#!/bin/sh case $BLOCK_BUTTON in 1) xidletog ;; diff --git a/xidletog b/xidletog index b5e996c..b274851 100755 --- a/xidletog +++ b/xidletog @@ -1,4 +1,4 @@ -#!/sbin/sh +#!/bin/sh if [ ! -f /tmp/xorg-awake ]; then touch /tmp/xorg-awake -- cgit v1.2.3