From c4d96716c05c41a3b18f2326cb588cd19246da5f Mon Sep 17 00:00:00 2001 From: zachir Date: Fri, 12 Aug 2022 04:30:51 -0500 Subject: initial commit --- .gitignore | 1 + LICENSE | 11 ++++++ README.md | 16 +++++++++ barmenu | 7 ++++ barmenu_run | 3 ++ battery | 21 +++++++++++ browser | 16 +++++++++ bsc | 5 +++ bspt | 29 +++++++++++++++ clock | 12 +++++++ cpu | 16 +++++++++ crcparse | 13 +++++++ crypto | 59 ++++++++++++++++++++++++++++++ disk | 20 +++++++++++ dmenu_keepass | 30 ++++++++++++++++ dmpv | 46 ++++++++++++++++++++++++ fdc | 5 +++ ffc | 5 +++ filter_scr | 4 +++ gettags | 7 ++++ herbsttags | 3 ++ hwinmv | 3 ++ infloop | 6 ++++ internet | 18 ++++++++++ launch_polybar.sh | 11 ++++++ liberclip | 6 ++++ lwc | 5 +++ memory | 12 +++++++ monattach | 22 ++++++++++++ mondetach | 10 ++++++ mpdup | 8 +++++ mprisctl | 59 ++++++++++++++++++++++++++++++ music | 24 +++++++++++++ nettraf | 28 +++++++++++++++ notify-iptables | 8 +++++ notify-sound.sh | 15 ++++++++ passmenu | 35 ++++++++++++++++++ qbc | 18 ++++++++++ sigdwmb | 13 +++++++ slockd | 12 +++++++ slocksleep | 3 ++ songgrab | 105 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ sortsongs | 10 ++++++ startvm | 4 +++ startxw | 9 +++++ svlogc | 4 +++ swayidlechk | 3 ++ swayidletog | 9 +++++ tagimg | 7 ++++ tagmp3 | 79 ++++++++++++++++++++++++++++++++++++++++ todo | 3 ++ toggle | 9 +++++ toggletouchpad | 14 ++++++++ tsoff | 13 +++++++ tson | 13 +++++++ usvlogc | 5 +++ volume | 23 ++++++++++++ waytoggle | 7 ++++ xidlechk | 12 +++++++ xidletog | 13 +++++++ 60 files changed, 987 insertions(+) create mode 100644 .gitignore create mode 100644 LICENSE create mode 100644 README.md create mode 100755 barmenu create mode 100755 barmenu_run create mode 100755 battery create mode 100755 browser create mode 100755 bsc create mode 100755 bspt create mode 100755 clock create mode 100755 cpu create mode 100755 crcparse create mode 100755 crypto create mode 100755 disk create mode 100755 dmenu_keepass create mode 100755 dmpv create mode 100755 fdc create mode 100755 ffc create mode 100755 filter_scr create mode 100755 gettags create mode 100755 herbsttags create mode 100755 hwinmv create mode 100755 infloop create mode 100755 internet create mode 100755 launch_polybar.sh create mode 100755 liberclip create mode 100755 lwc create mode 100755 memory create mode 100755 monattach create mode 100755 mondetach create mode 100755 mpdup create mode 100755 mprisctl create mode 100755 music create mode 100755 nettraf create mode 100755 notify-iptables create mode 100755 notify-sound.sh create mode 100755 passmenu create mode 100755 qbc create mode 100755 sigdwmb create mode 100755 slockd create mode 100755 slocksleep create mode 100755 songgrab create mode 100755 sortsongs create mode 100755 startvm create mode 100755 startxw create mode 100755 svlogc create mode 100755 swayidlechk create mode 100755 swayidletog create mode 100755 tagimg create mode 100755 tagmp3 create mode 100755 todo create mode 100755 toggle create mode 100755 toggletouchpad create mode 100755 tsoff create mode 100755 tson create mode 100755 usvlogc create mode 100755 volume create mode 100755 waytoggle create mode 100755 xidlechk create mode 100755 xidletog diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3364861 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +testing/ diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..32cf95e --- /dev/null +++ b/LICENSE @@ -0,0 +1,11 @@ +Copyright 2020-2022 Zachary Smith + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + +3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..e83cf58 --- /dev/null +++ b/README.md @@ -0,0 +1,16 @@ +# ZachIR's Cabal of Scripts + +These scripts are provided without any warranty. If you want to use them, you +should copy them out of this directory to a place on your path, as I change them +arbitrarily and on a whim. I don't like to remove functionality; generally my +changes either add something, or just improve POSIX compliance, but either way +you should probably expect at least one of them to functionally change whenever +this repo updates. + +That said, I also hope you will find them useful. These are scripts I have +either written, or very substantially modified (i.e. the majority of the source +code is mine). If you care about licensing, these are all licensed under the MIT +license, as are all of my scripts. + +If you have suggestions to improve the quality of them, I would be happy to +accept them. diff --git a/barmenu b/barmenu new file mode 100755 index 0000000..a43a079 --- /dev/null +++ b/barmenu @@ -0,0 +1,7 @@ +#!/sbin/sh + +if [ -z "$WAYLAND_DISPLAY" -a -n "$DISPLAY" ]; then + dmenu -i -F $@ +else + bemenu $(echo $@ | sed 's/-h/-H/') +fi diff --git a/barmenu_run b/barmenu_run new file mode 100755 index 0000000..6ff709f --- /dev/null +++ b/barmenu_run @@ -0,0 +1,3 @@ +#!/sbin/sh + +dmenu_path | barmenu "$@" | ${SHELL:-"/bin/sh"} & diff --git a/battery b/battery new file mode 100755 index 0000000..fb5349c --- /dev/null +++ b/battery @@ -0,0 +1,21 @@ +#!/sbin/sh + +case $BLOCK_BUTTON in + 2) notify-send "Battery module" "- : discharging +X : not charging +? : unknown ++ : charging +| : charged +! : battery very low!" ;; + 6) "$TERMINAL" -e "$EDITOR" "$0" ;; +esac + +ls /sys/class/power_supply/ | grep -i bat | head -1 | while read battery; +do + capacity=$(cat "/sys/class/power_supply/$battery"/capacity) || break + status=$(sed "s/[Dd]ischarging/-/;s/[Nn]ot charging/X/;s/[Cc]harging/+/;s/[Uu]nknown/?/;s/[Ff]ull/|/" "/sys/class/power_supply/$battery"/status) + + [ "$capacity" -le 25 ] && [ "$status" = "!" ] && warn="!" + printf "[%s%s%s]" "$status" "$warn" "$capacity" + unset warn +done | sed 's/ *$//' diff --git a/browser b/browser new file mode 100755 index 0000000..36dfbc7 --- /dev/null +++ b/browser @@ -0,0 +1,16 @@ +#!/sbin/sh +[ -z "$BROWSER" ] && BROWSER="qbc" +BROWSERS="qbc +bsc +ffc +lwc" +if [ `echo "$@" | cut -d'/' -f3` == "yewtu.be" ]; then + BROWSERS=`printf "mpv\n%s" "$BROWSERS"` +fi +brow=`printf "xclip\n%s" "$BROWSERS" | barmenu -l 15` +[ -z "$brow" ] && exit +if [ "$brow" = "xclip" ]; then + echo -n $@ | tr -d "\n" | xclip -selection clipboard +else + $brow $@ +fi diff --git a/bsc b/bsc new file mode 100755 index 0000000..b0e5409 --- /dev/null +++ b/bsc @@ -0,0 +1,5 @@ +#!/sbin/sh +PROFILES=`grep 'Path=' ~/.moonchild\ productions/basilisk/profiles.ini | cut -d'.' -f2` +CHOSEN=`echo "$PROFILES" | barmenu -l 15` +[ -z "$CHOSEN" ] && exit 2 +basilisk -P "$CHOSEN" diff --git a/bspt b/bspt new file mode 100755 index 0000000..8fed85a --- /dev/null +++ b/bspt @@ -0,0 +1,29 @@ +#!/sbin/sh + +get_cmd () { + echo "$@" | sed "s/"$1" //" +} + +toggle_sp() { + id="$(xdotool search --class "$1")" + if [ "$id" != "" ]; then + bspc node "$id" --flag hidden -f + fi +} + +spawn_sp() { + st -c "$1" -g 100x40 -e "${@:2}" +} + +unset __SP_EXISTS + +pgrep -x `get_cmd $@` && __SP_EXISTS=y + +if [ -z "$__SP_EXISTS" ]; then + st -c "$1" -g 100x40 -e "$(get_cmd $@)" +else + id="$(xdotool search --class $1)" + if [ "$id" != "" ]; then + bspc node "$id" --flag hidden -f + fi +fi diff --git a/clock b/clock new file mode 100755 index 0000000..81397af --- /dev/null +++ b/clock @@ -0,0 +1,12 @@ +#!/sbin/sh + +case $BLOCK_BUTTON in + 1) notify-send "This Month" "$(cal --color=always | sed "s/..7m//;s/..27m/<\/spawn<\/b>/")" && notify-send "Appointments" "$(calcurse -D ~/.config/calcurse -d3)" ;; + 2) notify-send "Time/date module" "\- Left click to show upcoming appointmnets for the next three days via \`calcurse -d3\` and show the month via \`cal\` +- Middle click to show this message +- Right click to open calcurse" ;; + 3) setsid -f "$TERMINAL" -e calcurse -D ~/.config/calcurse ;; + 6) "$TERMINAL" -e "$EDITOR" "$0" ;; +esac + +printf "[%s]" "$(date "+%Y %b %d (%a) %I:%M%p")" diff --git a/cpu b/cpu new file mode 100755 index 0000000..283cd40 --- /dev/null +++ b/cpu @@ -0,0 +1,16 @@ +#!/sbin/sh + +case $BLOCK_BUTTON in + 1) notify-send "CPU hogs" "$(ps axch -o comm,%cpu --sort=-%cpu | head)\\n(100% per core)" ;; + 2) notify-send "CPU module" "\- Shows CPU usage. +- Click to show intensive progresses. +- Middle click to show this tip +- Right click to open htop" ;; + 3) setsid -f "$TERMINAL" -e htop ;; + 6) "$TERMINAL" -e "$EDITOR" "$0" ;; +esac + +usage=$(mpstat 1 1 | sed '1,4d;s/.* //') +output="$(echo $usage | awk '{printf ("%2.2f", (100 - $1))}' | cut -c-4)" +echo -n "[$output%]" + diff --git a/crcparse b/crcparse new file mode 100755 index 0000000..ee823b1 --- /dev/null +++ b/crcparse @@ -0,0 +1,13 @@ +#!/sbin/sh + +if [ -n "$XDG_CONFIG_HOME" ]; then + CONPATH="$XDG_CONFIG_HOME" +elif [ -d "$HOME/.config" ]; then + CONPATH="$HOME/.config" +else + CONPATH="$HOME" +fi + +FILE="$CONPATH/computerrc" + +grep $1 "$FILE" | cut -d'=' -f2 diff --git a/crypto b/crypto new file mode 100755 index 0000000..736d696 --- /dev/null +++ b/crypto @@ -0,0 +1,59 @@ +#!/sbin/sh + +# Shows the price for desired cryptocurrencies. Module updates automatically +# every calendar day, but can also be updated with a middle click. + +# Currencies should be ;-separated: +# human-readable name;urlname;icon +#coins="Bitcoin;btc;💰 +#Etherium;eth;🍸 +#Basic Attention Token;bat;🦁 +#LBC;lbc;📚 +#Monero;xmr;" +coins="Etherium;eth;e +Bitcoin;btc;b +Monero;xmr;m" + +# Directory where currency info is stored. +dir="${XDG_DATA_HOME:-$HOME/.local/share}/crypto-prices" + +getprices() { # The command to get the desired prices + printf "🔃 "; printprices + { rm -rf "${dir:?}/*" + echo "$coins" | while IFS=';' read -r human web icon; do + val="$(curl -s "rate.sx/1$web")" && + echo "$icon;$val;$human" > "$dir/$web" + done; [ -d "$dir" ] && touch "$dir" + pkill -RTMIN+13 "${STATUSBAR:-dwmblocks}" ;} & + exit + } + +printprices() { # Print/format all prices + for x in "$dir"/*; do + [ -f "$x" ] || break + icon=`cut -d';' -f1 "$x"` + price=`cut -d';' -f2 "$x"` + printf "[%s$%0.2f]" "$icon" "$price" + done | sed 's/ $/\n/' + } + +[ ! -d "$dir" ] && mkdir -p "$dir" && { getprices; exit ;} + +# If currencies haven't been updated today, try to update them. +[ "$(stat -c %x "$HOME/.local/share/crypto-prices" | cut -d' ' -f1)" != "$(date '+%Y-%m-%d')" ] && + { ping -q -c 1 1.1.1.1 >/dev/null 2>&1 && getprices || exit ;} + +case $BLOCK_BUTTON in + 1) uptime="$(date -d "$(stat -c %x "$dir")" '+%D at %T' | sed "s|$(date '+%D')|Today|")" + notify-send "Exact prices in USD" "$(awk -F';' '{print $1, $3 ":\n\t$" $2}' "$dir"/*) +Last updated: + $uptime" ;; + 3) getprices ;; + 2) notify-send "💸 Crypto-currency module" "\- Left click for exact prices. +- Middle click to update. +- Shows 🔃 if updating prices. +- Manually add/remove currencies to list in the script." ;; + 6) "$TERMINAL" -e "$EDITOR" "$0" ;; +esac + +printprices diff --git a/disk b/disk new file mode 100755 index 0000000..abfb64d --- /dev/null +++ b/disk @@ -0,0 +1,20 @@ +#!/sbin/sh + +location=${1:-/} + +[ -d "$location" ] || exit + +case $BLOCK_BUTTON in + 1) notify-send "💽 Disk space" "$(df -h --output=target,used,size)" ;; + 3) notify-send "💽 Disk module" "\- Shows used hard drive space. +- Click to show all disk info." ;; + 6) "$TERMINAL" -e "$EDITOR" "$0" ;; +esac + +case "$location" in + "/home"* ) icon="h" ;; + "/mnt"* ) icon="m" ;; + *) icon="s";; +esac + +printf "[%s: %s]" "$icon" "$(df -h "$location" | awk ' /[0-9]/ {print $3 "/" $2}')" diff --git a/dmenu_keepass b/dmenu_keepass new file mode 100755 index 0000000..d87a4c8 --- /dev/null +++ b/dmenu_keepass @@ -0,0 +1,30 @@ +#!/sbin/sh + +HAS_KEYFILE="y" + +PASS_DIR="$HOME/Pass" +[ -n "$HAS_KEYFILE" ] && \ + KEYFILE=`ls $PASS_DIR | barmenu $@ -p 'keyfile:'` && \ + [ -n "$KEYFILE" ] && \ + KEYFILE_FLAG="-k" && \ + echo "$KEYFILE" || \ + exit 2 + +PASS_DB=`ls $PASS_DIR | barmenu $@ -p 'database:'` && \ + [ -f "$PASS_DIR/$PASS_DB" ] && + echo "$PASS_DB" || \ + exit 1 + + +PASS_WD=`barmenu -P $@ -p 'password:'` + +PASS_LS=`echo "$PASS_WD" | keepassxc-cli ls -Rf "$KEYFILE_FLAG" "$PASS_DIR/$KEYFILE" "$PASS_DIR/$PASS_DB"` + +PASSWORD_SEL=`echo "$PASS_LS" | barmenu $@ -p password` + +PASS_ATTR=`echo "username\npassword" | barmenu $@ -p "which attribute to copy?"` && \ + [ -z "$PASS_ATTR" ] && \ + PASS_ATTR="password" + +echo "$PASS_WD" | keepassxc-cli clip -a "$PASS_ATTR" "$KEYFILE_FLAG" "$PASS_DIR/$KEYFILE" "$PASS_DIR/$PASS_DB" "$PASSWORD_SEL" 15 + diff --git a/dmpv b/dmpv new file mode 100755 index 0000000..f5742f5 --- /dev/null +++ b/dmpv @@ -0,0 +1,46 @@ +#!/sbin/sh + +cd ~/Videos +case "$@" in + "-l") + LOOP="true" + ;; + "-h") + HELP="true" + ;; +esac + +playvid () { + while true; do + VIDEO=$(printf ".\n%s\n" "$(ls)" | uniq | barmenu "$@") + [ -z $VIDEO ] && exit + if [ "$VIDEO" = "." ]; then + break; + fi + [ -d $VIDEO ] && cd $VIDEO && continue + [ -f "$VIDEO" ] && break + pwd + done + mpv "$VIDEO" +} + +printhelp () { + printf \ + "Usage: dmpv [-l] [-h]\n" \ + "dmpv is a simple barmenu interface for playing content with mpv\n" \ + "dmpv assumes videos are stored in ~/Videos\n" \ + " -h\t\tprint this help message\n" \ + " -l\t\trun the prompt again after mpv exits\n" +} + +if [ -n "$HELP" ]; then + printhelp && exit 0 +elif [ -n "$LOOP" ]; then + while true; do + playvid || exit 0 + done +fi + +playvid + done +fi diff --git a/fdc b/fdc new file mode 100755 index 0000000..d7bc680 --- /dev/null +++ b/fdc @@ -0,0 +1,5 @@ +#!/sbin/sh +PROFILES=`grep 'Path=' ~/.firedragon/profiles.ini | cut -d'.' -f2` +CHOSEN=`echo "$PROFILES" | barmenu -l 15` +[ -z "$CHOSEN" ] && exit 2 +firedragon -P "$CHOSEN" diff --git a/ffc b/ffc new file mode 100755 index 0000000..6fd8e68 --- /dev/null +++ b/ffc @@ -0,0 +1,5 @@ +#!/sbin/sh +PROFILES=`grep 'Path=' ~/.mozilla/firefox/profiles.ini | cut -d'.' -f2` +CHOSEN=`echo "$PROFILES" | barmenu -l 15` +[ -z "$CHOSEN" ] && exit 2 +firefox -P "$CHOSEN" diff --git a/filter_scr b/filter_scr new file mode 100755 index 0000000..cfd06e4 --- /dev/null +++ b/filter_scr @@ -0,0 +1,4 @@ +#!/sbin/sh +grep -v '^\s*$' | + barmenu -l 10 + tr -d '\n' diff --git a/gettags b/gettags new file mode 100755 index 0000000..fc7ab88 --- /dev/null +++ b/gettags @@ -0,0 +1,7 @@ +#!/sbin/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=//' ;; + "ogg") echo "ogg" ;; + "*") echo "Unknown type" ;; +esac diff --git a/herbsttags b/herbsttags new file mode 100755 index 0000000..0e48804 --- /dev/null +++ b/herbsttags @@ -0,0 +1,3 @@ +#!/sbin/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 new file mode 100755 index 0000000..fa70d80 --- /dev/null +++ b/hwinmv @@ -0,0 +1,3 @@ +#!/sbin/sh + +herbstclient "$1" "$2" && polybar-msg hook herbstluftwm 1 diff --git a/infloop b/infloop new file mode 100755 index 0000000..5016117 --- /dev/null +++ b/infloop @@ -0,0 +1,6 @@ +#!/sbin/sh + +while true; do + echo "" > /dev/null + sleep 1111 +done diff --git a/internet b/internet new file mode 100755 index 0000000..5850a13 --- /dev/null +++ b/internet @@ -0,0 +1,18 @@ +#!/sbin/sh + +case $BLOCK_BUTTON in + 1) "$TERMINAL" -e nmtui; pkill -RTMIN+4 dwmblocks ;; + 2) notify-send "Internet module" "\- Click to connect +X : no wifi connection ++ : wifi connection +_ : no ethernet +- : ethernet working" ;; + 6) "$TERMINAL" -e "$EDITOR" "$0" ;; +esac + +case "$(cat /sys/class/net/w*/operstate 2>/dev/null)" in + down) wifiicon="X" ;; + up) wifiicon="$(awk '/^\s*w/ { print "+", int($3 * 100 / 70) "% " }' /proc/net/wireless)" ;; +esac + +printf "[%s%s]" "$wifiicon" "$(sed "s/down/_/;s/up/-/" /sys/class/net/e*/operstate 2>/dev/null)" diff --git a/launch_polybar.sh b/launch_polybar.sh new file mode 100755 index 0000000..b2c8745 --- /dev/null +++ b/launch_polybar.sh @@ -0,0 +1,11 @@ +#!/bin/sh + +killall polybar + +if type "xrandr"; then + for m in $(xrandr --query | grep " connected" | cut -d" " -f1); do + MONITOR=$m polybar --reload $1 & + done +else + polybar --reload $1 & +fi diff --git a/liberclip b/liberclip new file mode 100755 index 0000000..27d839d --- /dev/null +++ b/liberclip @@ -0,0 +1,6 @@ +#!/sbin/sh + +xclip -selection clipboard -o | \ + sed -e 's/www.youtube.com/yewtu.be/;s/youtu.be/yewtu.be/' \ + -e 's/www.reddit.com/libredd.it/' | \ + xclip -selection clipboard diff --git a/lwc b/lwc new file mode 100755 index 0000000..819861a --- /dev/null +++ b/lwc @@ -0,0 +1,5 @@ +#!/sbin/sh +PROFILES=`grep 'Path=' ~/.librewolf/profiles.ini | cut -d'.' -f2` +CHOSEN=`echo "$PROFILES" | barmenu -l 15` +[ -z "$CHOSEN" ] && exit 2 +librewolf -P "$CHOSEN" diff --git a/memory b/memory new file mode 100755 index 0000000..e9f8b2b --- /dev/null +++ b/memory @@ -0,0 +1,12 @@ +#!/sbin/sh + +case $BLOCK_BUTTON in + 1) notify-send "Memory hogs" "$(ps axch -o cmd:15,%mem --sort=-%mem | head)" ;; + 2) notify-send "Memory module" "\- Shows Memory Used/Total. +- Click to show memory hogs. +- Right click to open htop." ;; + 3) setsid -f "$TERMINAL" -e htop ;; + 6) "$TERMINAL" -e "$EDITOR" "$0" ;; +esac + +free --mebi | sed -n '2{p;q}' | awk '{printf ("[%2.2fGiB/%2.2fGiB]", ( $3 / 1024), ($2 / 1024))}' diff --git a/monattach b/monattach new file mode 100755 index 0000000..9eef6b6 --- /dev/null +++ b/monattach @@ -0,0 +1,22 @@ +#!/sbin/sh + +XSTATS="$(xrandr)" + +PRIMARY="$(echo "$XSTATS" | grep "primary" | awk '{print $1}')" +RIGHT=false + +for i in $@; do + case "$i" in + "right") + RIGHT="TRUE" ;; + "left") + RIGHT="FALSE" ;; + esac +done + +OUTPUT="$(echo "$XSTATS" | grep ' connected ' | grep -v '[0-9]*x[0-9]*+[0-9]*+[0-9]' | awk '{print $1}' | barmenu -h 24 -p 'Which output?')" +[ -z "$OUTPUT" ] && exit 2 + +[ "$RIGHT" = "TRUE" ] && ARGS="--right-of $PRIMARY" || ARGS="--left-of $PRIMARY" + +xrandr --output "$OUTPUT" --mode 1920x1080 $ARGS diff --git a/mondetach b/mondetach new file mode 100755 index 0000000..47d7d6a --- /dev/null +++ b/mondetach @@ -0,0 +1,10 @@ +#!/sbin/sh + +XSTATS="$(xrandr)" + +PRIMARY="$(echo "$XSTATS" | grep "primary" | awk '{print $1}')" + +OUTPUT="$(echo "$XSTATS" | grep '[0-9]*x[0-9]*+[0-9]*+[0-9]' | grep -v 'primary' | awk '{print $1}' | barmenu -h 24 -p 'Which output?')" +[ -z "$OUTPUT" ] && exit 2 + +xrandr --output "$OUTPUT" --off diff --git a/mpdup b/mpdup new file mode 100755 index 0000000..2a89a43 --- /dev/null +++ b/mpdup @@ -0,0 +1,8 @@ +#!/sbin/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. + +while true ; do + mpc idle >/dev/null && pkill -RTMIN+11 "${STATUSBAR:-dwmblocks}" +done diff --git a/mprisctl b/mprisctl new file mode 100755 index 0000000..6ea7745 --- /dev/null +++ b/mprisctl @@ -0,0 +1,59 @@ +#!/sbin/sh + +DMENU_PROMPT=$(playerctl -l | barmenu -p 'Players:') +[ -z "$DMENU_PROMPT" ] && exit 1 + +PLAYERCONTROLS_PROMPT=$(echo "play +pause +play-pause +stop +next +previous +position +volume +status +shuffle" | barmenu -p 'Action:') +[ -z "$PLAYERCONTROLS_PROMPT" ] && exit 1 + +case "$PLAYERCONTROLS_PROMPT" in + "pause"|"play"|"play-pause"|"stop"|"next"|"previous") + playerctl -p "$DMENU_PROMPT" "$PLAYERCONTROLS_PROMPT" + ;; + "position") + VALUE=$(seq -100 5 +100 | grep -v '^0$' | sed 's/^[0-9]/\+&/' | barmenu -p 'Position:') + [ -z "$VALUE" ] && exit 1 + playerctl -p "$DMENU_PROMPT" "$PLAYERCONTROLS_PROMPT" "$VALUE" + ;; + "volume") + VALUE=$(set 0 5 100 |barmenu -p 'Volume:') + [ -z "$VALUE" ] && exit 1 + playerctl -p "$DMENU_PROMPT" "$PLAYERCONTROLS_PROMPT" "$VALUE" + ;; + "status") + STATUS_MSG=$(playerctl -p "$DMENU_PROMPT" "$PLAYERCONTROLS_PROMPT") + notify-send "$DMENU_PROMPT status" "$STATUS_MSG" + ;; + "shuffle") + VALUE=$(echo "On +Off +Toggle +Status" | barmenu -p "Shuffle:") + [ -z "$VALUE" ] && exit 1 + case "$VALUE" in + "On"|"Off"|"Toggle") + playerctl -p "$DMENU_PROMPT" "$PLAYERCONTROLS_PROMPT" "$VALUE" + ;; + "Status") + STATUS_MSG=$(playerctl -p "$DMENU_PROMPT" "$PLAYERCONTROLS_PROMPT") + notify-send "$DMENU_PROMPT shuffle status" "$STATUS_MSG" + ;; + *) + exit 1 + ;; + esac + ;; + *) + exit 1 + ;; +esac +exit 0 diff --git a/music b/music new file mode 100755 index 0000000..2ec8aec --- /dev/null +++ b/music @@ -0,0 +1,24 @@ +#!/sbin/sh + +filter() { + if [ `pgrep -x mpd` ]; then + MPCSTAT="$(mpc status)" ; + printf "%s%s%s" "$(echo $MPCSTAT | head -1 | grep -v '^volume' | cut -d'-' -f1 | sed 's/ $//' | cut -c-10)" "$(echo $MPCSTAT | grep -vq '^volume' && echo ' - ')" "$(echo $MPCSTAT | head -1 | grep -v '^volume' | cut -d'-' -f2 | sed 's/^ //' | cut -c-10)" + fi +} + +pidof -x mpdup >/dev/null 2>&1 || mpdup >/dev/null 2>&1 & + +case $BLOCK_BUTTON in + 1) mpc status | filter ; setsid -f "$TERMINAL" -e ncmpcpp ;; # left click, open music player + 3) mpc toggle | filter ;; # right click, pause/unpause + 2) mpc status | filter ; notify-send "🎵 Music module" "\- Shows mpd song playing. +- Italic when paused. +- Left click opens ncmpcpp. +- Middle click pauses. +- Scroll changes track.";; # right click, pause/unpause + 4) mpc prev | filter ;; # scroll up, previous + 5) mpc next | filter ;; # scroll down, next + 6) mpc status | filter ; "$TERMINAL" -e "$EDITOR" "$0" ;; + *) filter ;; +esac diff --git a/nettraf b/nettraf new file mode 100755 index 0000000..4bd0850 --- /dev/null +++ b/nettraf @@ -0,0 +1,28 @@ +#!/sbin/sh + +# Module showing network traffic. Shows how much data has been received (RX) or +# transmitted (TX) since the previous time this script ran. So if run every +# second, gives network traffic per second. + +case $BLOCK_BUTTON in + 3) notify-send "🌐 Network traffic module" "🔻: Traffic received +🔺: Traffic transmitted" ;; + 6) "$TERMINAL" -e "$EDITOR" "$0" ;; +esac + +update() { + sum=0 + for arg; do + read -r i < "$arg" + sum=$(( sum + i )) + done + cache=${XDG_CACHE_HOME:-$HOME/.cache}/${1##*/} + [ -f "$cache" ] && read -r old < "$cache" || old=0 + printf %d\\n "$sum" > "$cache" + printf %d\\n $(( (sum - old) / 1024 )) +} + +rx=$(update /sys/class/net/[ew]*/statistics/rx_bytes) +tx=$(update /sys/class/net/[ew]*/statistics/tx_bytes) + +printf "🔻%dKiB 🔺%dKiB\\n" "$rx" "$tx" diff --git a/notify-iptables b/notify-iptables new file mode 100755 index 0000000..bce7938 --- /dev/null +++ b/notify-iptables @@ -0,0 +1,8 @@ +#!/sbin/sh + +LIST="$(doas iptables -S)" +LIST6="$(doas ip6tables -S)" +LISTN="$(doas nft list ruleset)" +notify-send "IPTables rules" "IPTables Rules:\n$LIST" +notify-send "IP6Tables rules" "IP6Tables Rules:\n$LIST6" +notify-send "NFTables rules" "NFTables Rules:\n$LISTN" diff --git a/notify-sound.sh b/notify-sound.sh new file mode 100755 index 0000000..84170d2 --- /dev/null +++ b/notify-sound.sh @@ -0,0 +1,15 @@ +#!/bin/sh +SILENT_FILE="/tmp/notify-sound-silent" +case "$1" in + "on") + rm -rf "$SILENT_FILE" + notify-send "Notification sound on" + ;; + "off") + touch "$SILENT_FILE" + notify-send "Notification sound off" + ;; + *) + [ ! -f "$SILENT_FILE" ] && paplay ~/.local/share/sounds/notification.flac + ;; +esac diff --git a/passmenu b/passmenu new file mode 100755 index 0000000..19a7a32 --- /dev/null +++ b/passmenu @@ -0,0 +1,35 @@ +#!/usr/bin/env bash + +shopt -s nullglob globstar + +typeit=0 +if [[ $1 == "--type" ]]; then + typeit=1 + shift +fi + +if [[ -n $WAYLAND_DISPLAY ]]; then + barmenu=barmenu + xdotool="ydotool type --file -" +elif [[ -n $DISPLAY ]]; then + barmenu=barmenu + xdotool="xdotool type --clearmodifiers --file -" +else + echo "Error: No Wayland or X11 display detected" >&2 + exit 1 +fi + +prefix=${PASSWORD_STORE_DIR-~/.password-store} +password_files=( "$prefix"/**/*.gpg ) +password_files=( "${password_files[@]#"$prefix"/}" ) +password_files=( "${password_files[@]%.gpg}" ) + +password=$(printf '%s\n' "${password_files[@]}" | "$barmenu" "$@") + +[[ -n $password ]] || exit + +if [[ $typeit -eq 0 ]]; then + pass show -c "$password" 2>/dev/null +else + pass show "$password" | { IFS= read -r pass; printf %s "$pass"; } | $xdotool +fi diff --git a/qbc b/qbc new file mode 100755 index 0000000..d44d0c0 --- /dev/null +++ b/qbc @@ -0,0 +1,18 @@ +#!/sbin/sh + +SESSIONS=`qbpm list` +[ -z "$SESSIONS" ] && qutebrowser $@ +CHOSEN=`printf "default\n$SESSIONS" | barmenu -l 15` +[ -z "$CHOSEN" ] && exit 2 +if [ -n "$CHOSEN" ]; then + if [ "$CHOSEN" = "default" ]; then + qutebrowser $@ + else + if [ -z `echo "$SESSIONS" | grep "$CHOSEN"` ]; then + qbpm new "$CHOSEN" + fi + qbpm launch "$CHOSEN" $@ + #qutebrowser -B "$HOME/.local/share/$CHOSEN" + fi +fi + diff --git a/sigdwmb b/sigdwmb new file mode 100755 index 0000000..b5942b0 --- /dev/null +++ b/sigdwmb @@ -0,0 +1,13 @@ +#!/sbin/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 + echo "$i" + pkill -RTMIN+`grep "$i" ~/.local/src/dwmblocks/config.h | sed -e 's/^\s*{".*",\s*[0-9]*,\s*//' -e 's/},$//' | head -1` dwmblocks + elif [ "$i" = "all" ]; then + for j in $BLOCKS; do + echo "$j" + pkill -RTMIN+`grep "$j" ~/.local/src/dwmblocks/config.h | sed -e 's/^\s*{".*",\s*[0-9]*,\s*//' -e 's/},$//' | head -1` dwmblocks + done + fi +done diff --git a/slockd b/slockd new file mode 100755 index 0000000..2c31320 --- /dev/null +++ b/slockd @@ -0,0 +1,12 @@ +#!/sbin/sh + +if [ -z "$WAYLAND_DISPLAY" ]; then + LOCKER=slock +else + LOCKER=waylock +fi + + +while [ 1 -gt 0 ]; do + $LOCKER && exit +done diff --git a/slocksleep b/slocksleep new file mode 100755 index 0000000..2bf9043 --- /dev/null +++ b/slocksleep @@ -0,0 +1,3 @@ +#!/sbin/sh +slockd & +sleep 1 && zzz diff --git a/songgrab b/songgrab new file mode 100755 index 0000000..914a56b --- /dev/null +++ b/songgrab @@ -0,0 +1,105 @@ +#!/sbin/sh + +# check flags +for i in $@; do + case "$i" in + "-"*) unset GETARTIST GETALBUM GETTITLE + esac + [ -n "$GETURL" ] && URL="$i" && unset GETURL + [ -n "$GETARTIST" ] && ARTIST="$ARTIST $i" + [ -n "$GETALBUM" ] && ALBUM="$ALBUM $i" + [ -n "$GETTITLE" ] && TITLE="$TITLE $i" + [ -n "$GETTRACKNUM" ] && TRACKNUM="$i" && unset GETTRACKNUM + [ -n "$GETYEAR" ] && YEAR="$i" && unset GETYEAR + case "$i" in + "-s") + SPLITTER_SELECTION="s" + ;; + "-l") + SPLITTER_SELECTION="a" + ;; + "-p") + SPLITTER_SELECTION="p" + ;; + "-u") + GETURL="y" + ;; + "-a") + GETARTIST="y" + ;; + "-A") + GETALBUM="y" + ;; + "-t") + GETTITLE="y" + ;; + "-T") + GETTRACKNUM="y" + ;; + "-y") + GETYEAR="y" + ;; + esac +done + +ARTIST=`echo $ARTIST | sed 's/^ //'` +ALBUM=`echo $ALBUM | sed 's/^ //'` +TITLE=`echo $TITLE | sed 's/^ //'` +echo "Artist: $ARTIST +Album: $ALBUM +Song: $TITLE +Number: $TRACKNUM +Year: $YEAR" + +# prompt to determine later tagging +if [ -z "$SPLITTER_SELECTION" ]; then + echo -n "Will the link be for a [p]laylist, a[l]bum video, or [s]ong video? " + read SPLITTER_SELECTION + echo "" +fi + +# prompt to get the URL +if [ -z "$URL" ]; then + echo -n "Enter the link: " + read URL + echo "" +fi + +# if song, don't download playlist +if [ "$SPLITTER_SELECTION" = "s" ]; then + SPLITTER_FLAGS="--no-playlist" +fi + +# download the video(s) +ls | grep -q "$(echo $URL | cut -d'=' -f2 | cut -d'&' -f1)" && echo "Already downloaded" || youtube-dl $SPLITTER_FLAGS --format bestaudio --restrict-filenames "$URL" + +# while loop to remove files from list +while true; do + ls | nl + echo -n "Enter the line number: " + read WHILE_RESPONSE + [ -z "$WHILE_RESPONSE" ] && break + rm -rf `ls | head -n "$WHILE_RESPONSE" | tail -1` +done + +# convert the m4a files to mp3 +for i in `ls *.m4a *.webm`; do + imp3=`echo "$i" | sed 's/\.m4a$/.mp3/;s/\.webm$/.mp3/'` + [ ! -f "$imp3" ] && ffmpeg -i "$i" -acodec mp3 "$imp3" || echo "File not converted" +done + +# fix names for suggestions +vimv + +# determine tagmp3 flags +FLAGS="" +[ -n "$ARTIST" ] && FLAGS="$FLAGS -a $ARTIST" +[ -n "$ALBUM" ] && FLAGS="$FLAGS -A $ALBUM" +[ -n "$TITLE" ] && FLAGS="$FLAGS -t $TITLE" +[ -n "$TRACKNUM" ] && FLAGS="$FLAGS -T $TRACKNUM" +[ -n "$YEAR" ] && FLAGS="$FLAGS -y $YEAR" + +# tag songs with tagmp3 +for i in `ls *.mp3`; do + tagmp3 $FLAGS "$i" +done diff --git a/sortsongs b/sortsongs new file mode 100755 index 0000000..510af26 --- /dev/null +++ b/sortsongs @@ -0,0 +1,10 @@ +#!/sbin/sh + +ls *.mp3 | while read i; do + DATA="$(gettags "$i")" + ARTIST=$(echo "$DATA" | cut -d'|' -f2) + ALBUM=$(echo "$DATA" | cut -d'|' -f1) + [ ! -d "$ARTIST"/"$ALBUM" ] && mkdir -p "$ARTIST"/"$ALBUM" + mv "$i" "$ARTIST"/"$ALBUM"/. + echo "$i" +done diff --git a/startvm b/startvm new file mode 100755 index 0000000..482bfbb --- /dev/null +++ b/startvm @@ -0,0 +1,4 @@ +#!/sbin/sh +SERVICES="libvirtd virtlockd virtlogd" +doas rsm start $SERVICES +virt-manager --no-fork && doas rsm stop $SERVICES diff --git a/startxw b/startxw new file mode 100755 index 0000000..0df25d7 --- /dev/null +++ b/startxw @@ -0,0 +1,9 @@ +#!/sbin/sh + + wayland=`crcparse "wayland"` + +if [ "$wayland" == "y" ]; then + `crcparse WC` +else + startx +fi diff --git a/svlogc b/svlogc new file mode 100755 index 0000000..7b77a67 --- /dev/null +++ b/svlogc @@ -0,0 +1,4 @@ +#!/sbin/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 new file mode 100755 index 0000000..60322b9 --- /dev/null +++ b/swayidlechk @@ -0,0 +1,3 @@ +#!/sbin/sh + +[ $(pidof swayidle) ] && echo "🌑" || echo "🌕" diff --git a/swayidletog b/swayidletog new file mode 100755 index 0000000..94e0eaf --- /dev/null +++ b/swayidletog @@ -0,0 +1,9 @@ +#!/sbin/sh + +SWIDLE=$(pidof swayidle) +if [ ! -z "$SWIDLE" ] ; then + killall swayidle +else + swayidle timeout 300 waylock & +fi +pkill -RTMIN+8 waybar diff --git a/tagimg b/tagimg new file mode 100755 index 0000000..4aca06e --- /dev/null +++ b/tagimg @@ -0,0 +1,7 @@ +#!/sbin/sh + +ls | while read i; do + ls "$i"| while read j; do + mid3v2 -p "$i"/"$j"/thumb.jpg "$i"/"$j"/*.{mp3,flac} + done +done diff --git a/tagmp3 b/tagmp3 new file mode 100755 index 0000000..6ecb6f8 --- /dev/null +++ b/tagmp3 @@ -0,0 +1,79 @@ +#!/sbin/sh + +FILENAME=`echo $@ | rev | cut -d' ' -f1 | rev` + +# check for flags +for i in $@; do + case "$i" in + "-"*) unset ARTISTFLAG ALBUMFLAG SONGFLAG + ;; + esac + [ -n "$ARTISTFLAG" ] && ARTISTNAME="$ARTISTNAME $i" + [ -n "$ALBUMFLAG" ] && ALBUMNAME="$ALBUMNAME $i" + [ -n "$SONGFLAG" ] && SONGNAME="$SONGNAME $i" + [ -n "$TRACKFLAG" ] && TRACKNUMBER="$i" && unset TRACKFLAG + [ -n "$YEARFLAG" ] && YEARNUMBER="$i" && unset YEARFLAG + case "$i" in + "-a") + ARTISTFLAG="y" + ;; + "-A") + ALBUMFLAG="y" + ;; + "-t") + SONGFLAG="y" + ;; + "-T") + TRACKFLAG="y" + ;; + "-y") + YEARFLAG="y" + ;; + esac +done + +ARTISTNAME=`echo $ARTISTNAME | sed 's/^ //'` +ALBUMNAME=`echo $ALBUMNAME | sed 's/^ //'` +SONGNAME=`echo $SONGNAME | sed 's/^ //'` + +# guess artist name from title +ARTISTNAME_GUESS=`echo "$FILENAME" | cut -d'-' -f1 | sed 's/_*$//;s/_/ /g'` + +# guess album name from title +ALBUMNAME_GUESS=`echo "$FILENAME" | cut -d'-' -f2 | sed 's/^_*//;s/_*$//;s/_/ /g'` + +# guess track number from title +TRACKNUMBER_GUESS=`echo "$FILENAME" | cut -d'-' -f3 | cut -d'_' -f2` + +# guess song name from title +SONGNAME_GUESS=`echo "$FILENAME" | cut -d'-' -f3 | sed 's/^_[0-9]*_//;s/_/ /g;s/\.mp3$//'` + +# get the artist name input +[ -z "$ARTISTNAME" ] && echo "Input the Artist name:\nGuessed name is $ARTISTNAME_GUESS" && read ARTISTNAME +[ -z "$ARTISTNAME" ] && ARTISTNAME="$ARTISTNAME_GUESS" + +echo "$ARTISTNAME" + +# get the album name input +[ -z "$ALBUMNAME" ] && printf "Input the Album name:\nGuessed name is %s" "$ALBUMNAME_GUESS" && read ALBUMNAME +[ -z "$ALBUMNAME" ] && ALBUMNAME="$ALBUMNAME_GUESS" + +echo "$ALBUMNAME" + +# get the track number input +[ -z "$TRACKNUMBER" ] && printf "Input the track number:\nGuessed number is %s" "$TRACKNUMBER_GUESS" && read TRACKNUMBER +[ -z "$TRACKNUMBER" ] && TRACKNUMBER="$TRACKNUMBER_GUESS" + +echo "$TRACKNUMBER" + +# get the song name input +[ -z "$SONGNAME" ] && printf "Input the song name:\nGuessed name is %s" "$SONGNAME_GUESS" && read SONGNAME +[ -z "$SONGNAME" ] && SONGNAME="$SONGNAME_GUESS" + +echo "$SONGNAME" + +# get the year input +[ -z "$YEARNUMBER" ] && echo "Input the year number:" && read YEARNUMBER +[ ! -z "$YEARNUMBER" ] && mid3v2 -y "$YEARNUMBER" $FILENAME +# set tags for file +mid3v2 -a "$ARTISTNAME" -A "$ALBUMNAME" -t "$SONGNAME" -T "$TRACKNUMBER" $FILENAME diff --git a/todo b/todo new file mode 100755 index 0000000..e90965f --- /dev/null +++ b/todo @@ -0,0 +1,3 @@ +#!/sbin/sh + +"${EDITOR:-nvim}" ~/todo.txt diff --git a/toggle b/toggle new file mode 100755 index 0000000..28dda1e --- /dev/null +++ b/toggle @@ -0,0 +1,9 @@ +#!/sbin/sh + +if type disown >/dev/null; then + killall $1 ; $@ >/dev/null & disown +elif type setsid >/dev/null; then + killall $1 ; setsid -f $@ >/dev/null & +else + sh -c "killall $1 ; $@ >/dev/null &" +fi diff --git a/toggletouchpad b/toggletouchpad new file mode 100755 index 0000000..553cf60 --- /dev/null +++ b/toggletouchpad @@ -0,0 +1,14 @@ +#!/sbin/sh +CONTROLLER=`which synclient` +[ -x "$CONTROLLER" ] && SYNCLIENT=y || CONTROLLER=`which xinput` +[ ! -x "$CONTROLLER" ] && XINPUT=y || echo "This script requires X11" +[ -n "$SYNCLIENT" ] && TOUCHPADSTATE=`synclient | grep "TouchpadOff" | sed -e "s/^\s*TouchpadOff\s*=\s*//" -e "s/1/y/" -e "s/0/n/"` || unset SYNCLIENT +[ -n "$XINPUT" ] && DEVICE=`echo $($CONTROLLER) | grep -i touchpad | sed -e 's/.*id\=//' -e 's/\s*\[.*//'` || unset DEVICE +[ -n "$XINPUT" -a -n "$DEVICE" ] && TOUCHPADSTATE=`xinput list-props $DEVICE | grep -i 'device enabled' | sed -e 's/.*:\s*//' -e 's/0/y/' -e 's/1/n/'` || unset XINPUT +echo "$TOUCHPADSTATE $SYNCLIENT $XINPUT" +[ -z "$SYNCLIENT" -a -z "$XINPUT" -o -z "$TOUCHPADSTATE" ] && echo "Couldn't use either synclient or xinput" && exit +[ ! "$TOUCHPADSTATE" = "y" ] || unset TOUCHPADSTATE +[ -z "$TOUCHPADSTATE" -a -n "$SYNCLIENT" ] && synclient "touchpadoff=0" && notify-send "Enabled Touchpad" +[ -n "$TOUCHPADSTATE" -a -n "$SYNCLIENT" ] && synclient "touchpadoff=1" && notify-send "Disabled Touchpad" +[ -z "$TOUCHPADSTATE" -a -n "$XINPUT" ] && xinput enable "$DEVICE" && notify-send "Enabled Touchpad" +[ -n "$TOUCHPADSTATE" -a -n "$XINPUT" ] && xinput disable "$DEVICE" && notify-send "Disabled Touchpad" diff --git a/tsoff b/tsoff new file mode 100755 index 0000000..bf9291d --- /dev/null +++ b/tsoff @@ -0,0 +1,13 @@ +#!/sbin/sh + +if [ -n "$XDG_CONFIG_HOME" ]; then + CONPATH="$XDG_CONFIG_HOME" +elif [ -d "$HOME/.config/" ]; then + CONPATH="$HOME/.config" +else + CONPATH="$HOME" +fi + +TSNAME="$(crcparse 'tsname')" + +xinput disable "$(xinput list | grep "$TSNAME" | grep 'pointer' | sed 's/\s/\n/g' | grep id | sed 's/^id=//')" diff --git a/tson b/tson new file mode 100755 index 0000000..c8d137b --- /dev/null +++ b/tson @@ -0,0 +1,13 @@ +#!/sbin/sh + +if [ -n "$XDG_CONFIG_HOME" ]; then + CONPATH="$XDG_CONFIG_HOME" +elif [ -d "$HOME/.config/" ]; then + CONPATH="$HOME/.config" +else + CONPATH="$HOME" +fi + +TSNAME="$(crcparse 'tsname')" + +xinput enable "$(xinput list | grep "$TSNAME" | grep 'pointer' | sed 's/\s/\n/g' | grep id | sed 's/^id=//')" diff --git a/usvlogc b/usvlogc new file mode 100755 index 0000000..efebad2 --- /dev/null +++ b/usvlogc @@ -0,0 +1,5 @@ +#!/sbin/sh +SERV_NAME=$(echo "$1" | sed 's/\/log$//') +SVDIR="$HOME"/.local/sv +SVLOGDIR="$HOME"/.local/log +[ -f "$SVLOGDIR/$SERV_NAME"/current ] && tac "$SVLOGDIR"/"$(echo "$1" | sed 's/\/log$//')"/current | less || echo "Cannot read log" diff --git a/volume b/volume new file mode 100755 index 0000000..1c67faf --- /dev/null +++ b/volume @@ -0,0 +1,23 @@ +#!/sbin/sh + +case $BLOCK_BUTTON in + 1) + pgrep -x pipewire >/dev/null && MIXER="pulsemixer" || \ + pgrep -x pulseaudio >/dev/null && MIXER="pulsemixer" || \ + MIXER="alsamixer" + setsid -f $TERMINAL -e $MIXER + ;; + 2) notify-send "Volume module" "\- Shows volume, X if muted. +- Middle click to show this message. +- Right click to mute. +- Scroll to change." ;; + 3) volsv -t ;; + 4) volsv -i ;; + 5) volsv -d ;; + 6) "$TERMINAL" -e "$EDITOR" "$0" ;; +esac +volstat="$(volsv -v)" +mutstat="$(volsv -g)" +echo "$mutstat" | grep -q "\[off\]" && printf "[X]" && exit +vol="$(echo "$volstat" | grep '[0-9]\+%' | sed "s,.* \([0-9]\+\)%.*,\1,;1q")" +printf "[%s]" "$vol" diff --git a/waytoggle b/waytoggle new file mode 100755 index 0000000..8da651d --- /dev/null +++ b/waytoggle @@ -0,0 +1,7 @@ +#!/sbin/sh + +if [ -n "$(pgrep -x waybar)" ]; then + pkill waybar +else + waybar & +fi diff --git a/xidlechk b/xidlechk new file mode 100755 index 0000000..7611f89 --- /dev/null +++ b/xidlechk @@ -0,0 +1,12 @@ +#!/sbin/sh + +case $BLOCK_BUTTON in + 1) xidletog ;; + 2) notify-send "XIdleTog module" "\- Shows xidle status. +- Middle click to show this message. +- Right click to toggle xidle" ;; + 3) xidletog ;; + 6) "$TERMINAL" -e "$EDITOR" "$0" +esac + +[ -f /tmp/xorg-awake ] && echo "🌑" || echo "🌕" diff --git a/xidletog b/xidletog new file mode 100755 index 0000000..19ca5f9 --- /dev/null +++ b/xidletog @@ -0,0 +1,13 @@ +#!/sbin/sh + +if [ ! -f /tmp/xorg-awake ]; then + touch /tmp/xorg-awake + xset -dpms + xset s off +else + rm -rf /tmp/xorg-awake + xset +dpms + xset s on +fi + +pkill -RTMIN+19 dwmblocks -- cgit v1.2.3