From e8ea24149aa16c193c4638b3614bc16fa5ebca97 Mon Sep 17 00:00:00 2001
From: Luca Bilke <luca@bil.ke>
Date: Thu, 1 Feb 2024 20:16:45 +0100
Subject: [PATCH] changes to script storage

---
 .config/X11/xsession.d/80autostart            |  2 +-
 .config/lf/preview/preview                    |  4 ++--
 {.local/bin => .config/lf/preview}/vidthumb   |  0
 .local/bin/prompt                             |  8 -------
 .local/bin/shortcuts                          |  4 +---
 .local/{bin => libexec}/cron/checkup          |  0
 .local/{bin => libexec}/cron/crontog          |  0
 .local/{bin => libexec}/cron/trash-prune      |  0
 .local/{bin => libexec}/daemons/remapd        |  0
 .local/{bin => libexec}/daemons/sbd-battery   |  0
 .local/{bin => libexec}/daemons/sbd-music     |  0
 .local/{bin => libexec}/daemons/sbd-playerctl |  0
 .local/{bin => libexec/dwm}/brightness-notify |  0
 .local/{bin => libexec/dwm}/dmenuhandler      |  0
 .local/{bin => libexec/dwm}/dmenumaim         |  0
 .../{bin/mounter => libexec/dwm/dmenumount}   | 24 +++++++++----------
 .local/{bin => libexec/dwm}/dmenumountcifs    |  0
 .local/{bin => libexec/dwm}/dmenupass         |  0
 .local/{bin => libexec/dwm}/dmenurecord       |  0
 .local/libexec/{ => dwm}/dmenusys             |  0
 .local/{bin => libexec/dwm}/dmenuumount       |  0
 .local/{bin => libexec/dwm}/dmenuunicode      |  0
 .local/{bin => libexec/dwm}/pamixer-notify    |  0
 .local/{bin => libexec/dwm}/togcom            |  0
 .local/{bin => libexec/dwm}/togtp             |  0
 .local/libexec/statusbar/sb-battery           |  2 +-
 .local/libexec/statusbar/sb-cpu               |  2 +-
 .local/libexec/statusbar/sb-music             |  2 +-
 .local/libexec/statusbar/sb-playerctl         |  2 +-
 29 files changed, 20 insertions(+), 30 deletions(-)
 rename {.local/bin => .config/lf/preview}/vidthumb (100%)
 delete mode 100755 .local/bin/prompt
 rename .local/{bin => libexec}/cron/checkup (100%)
 rename .local/{bin => libexec}/cron/crontog (100%)
 rename .local/{bin => libexec}/cron/trash-prune (100%)
 rename .local/{bin => libexec}/daemons/remapd (100%)
 rename .local/{bin => libexec}/daemons/sbd-battery (100%)
 rename .local/{bin => libexec}/daemons/sbd-music (100%)
 rename .local/{bin => libexec}/daemons/sbd-playerctl (100%)
 rename .local/{bin => libexec/dwm}/brightness-notify (100%)
 rename .local/{bin => libexec/dwm}/dmenuhandler (100%)
 rename .local/{bin => libexec/dwm}/dmenumaim (100%)
 rename .local/{bin/mounter => libexec/dwm/dmenumount} (86%)
 rename .local/{bin => libexec/dwm}/dmenumountcifs (100%)
 rename .local/{bin => libexec/dwm}/dmenupass (100%)
 rename .local/{bin => libexec/dwm}/dmenurecord (100%)
 rename .local/libexec/{ => dwm}/dmenusys (100%)
 rename .local/{bin => libexec/dwm}/dmenuumount (100%)
 rename .local/{bin => libexec/dwm}/dmenuunicode (100%)
 rename .local/{bin => libexec/dwm}/pamixer-notify (100%)
 rename .local/{bin => libexec/dwm}/togcom (100%)
 rename .local/{bin => libexec/dwm}/togtp (100%)

diff --git a/.config/X11/xsession.d/80autostart b/.config/X11/xsession.d/80autostart
index 97f7e1a6..c9c721f5 100755
--- a/.config/X11/xsession.d/80autostart
+++ b/.config/X11/xsession.d/80autostart
@@ -14,6 +14,6 @@ start picom
 start unclutter -noevents
 start dunst
 start dwmblocks
-start remapd
+start $HOME/.local/libexec/daemons/remapd
 start syncthingtray
 start system-config-printer-applet
diff --git a/.config/lf/preview/preview b/.config/lf/preview/preview
index 74763396..78eccf0a 100755
--- a/.config/lf/preview/preview
+++ b/.config/lf/preview/preview
@@ -31,8 +31,8 @@ image() {
 
 video() {
 	f=$1 w=$2 h=$3 x=$4 y=$5
-	thumb="$(vidthumb "$f")" || (
-		printf "%b" "\033[31mvidthumb script not in path\033[0m"
+	thumb="$("$HOME/.config/lf/preview/vidthumb" "$f")" || (
+		printf "%b" "${RED}vidthumb failed to execute${RESET}"
 		return 1
 	)
 	image "$thumb" "$w" "$h" "$x" "$y"
diff --git a/.local/bin/vidthumb b/.config/lf/preview/vidthumb
similarity index 100%
rename from .local/bin/vidthumb
rename to .config/lf/preview/vidthumb
diff --git a/.local/bin/prompt b/.local/bin/prompt
deleted file mode 100755
index ada2c47c..00000000
--- a/.local/bin/prompt
+++ /dev/null
@@ -1,8 +0,0 @@
-#!/bin/sh
-
-# A dmenu binary prompt script.
-# Gives a dmenu prompt labeled with $1 to perform command $2.
-# For example:
-# `./prompt "Do you want to shutdown?" "shutdown -h now"`
-
-[ "$(printf "No\\nYes" | dmenu -i -p "$1" -nb darkred -sb red -sf white -nf gray)" = "Yes" ] && $2
diff --git a/.local/bin/shortcuts b/.local/bin/shortcuts
index bd4a1508..6833daa2 100755
--- a/.local/bin/shortcuts
+++ b/.local/bin/shortcuts
@@ -5,14 +5,12 @@ bmdirs="$XDG_CONFIG_HOME/bookmarks/directories"
 bmfiles="$XDG_CONFIG_HOME/bookmarks/files"
 
 # Outputs
-shell_shortcuts="$ZDOTDIR/configs/autogenerated/shortcuts"
 zsh_named_dirs="$ZDOTDIR/configs/autogenerated/hashes"
 lf_files="$XDG_DATA_HOME/lf/shortcut-files"
 lf_dirs="$XDG_DATA_HOME/lf/shortcut-dirs"
 lf_shortcuts="$XDG_CONFIG_HOME/lf/shortcutrc"
 
-rm -f "$shell_shortcuts" "$lf_files" "$lf_dirs" "$lf_shortcuts" "$zsh_named_dirs" 2>/dev/null
-printf "# vim: filetype=sh\\nalias " >"$shell_shortcuts"
+rm -f "$lf_files" "$lf_dirs" "$lf_shortcuts" "$zsh_named_dirs" 2>/dev/null
 
 eval "echo \"$(cat "$bmdirs")\"" | awk "!/^\s*#/ && !/^\s*\$/ {gsub(\"\\\s*#.*$\",\"\");
   printf(\"hash -d %s=%s \n\",\$1,\$2)                           >> \"$zsh_named_dirs\"  ;
diff --git a/.local/bin/cron/checkup b/.local/libexec/cron/checkup
similarity index 100%
rename from .local/bin/cron/checkup
rename to .local/libexec/cron/checkup
diff --git a/.local/bin/cron/crontog b/.local/libexec/cron/crontog
similarity index 100%
rename from .local/bin/cron/crontog
rename to .local/libexec/cron/crontog
diff --git a/.local/bin/cron/trash-prune b/.local/libexec/cron/trash-prune
similarity index 100%
rename from .local/bin/cron/trash-prune
rename to .local/libexec/cron/trash-prune
diff --git a/.local/bin/daemons/remapd b/.local/libexec/daemons/remapd
similarity index 100%
rename from .local/bin/daemons/remapd
rename to .local/libexec/daemons/remapd
diff --git a/.local/bin/daemons/sbd-battery b/.local/libexec/daemons/sbd-battery
similarity index 100%
rename from .local/bin/daemons/sbd-battery
rename to .local/libexec/daemons/sbd-battery
diff --git a/.local/bin/daemons/sbd-music b/.local/libexec/daemons/sbd-music
similarity index 100%
rename from .local/bin/daemons/sbd-music
rename to .local/libexec/daemons/sbd-music
diff --git a/.local/bin/daemons/sbd-playerctl b/.local/libexec/daemons/sbd-playerctl
similarity index 100%
rename from .local/bin/daemons/sbd-playerctl
rename to .local/libexec/daemons/sbd-playerctl
diff --git a/.local/bin/brightness-notify b/.local/libexec/dwm/brightness-notify
similarity index 100%
rename from .local/bin/brightness-notify
rename to .local/libexec/dwm/brightness-notify
diff --git a/.local/bin/dmenuhandler b/.local/libexec/dwm/dmenuhandler
similarity index 100%
rename from .local/bin/dmenuhandler
rename to .local/libexec/dwm/dmenuhandler
diff --git a/.local/bin/dmenumaim b/.local/libexec/dwm/dmenumaim
similarity index 100%
rename from .local/bin/dmenumaim
rename to .local/libexec/dwm/dmenumaim
diff --git a/.local/bin/mounter b/.local/libexec/dwm/dmenumount
similarity index 86%
rename from .local/bin/mounter
rename to .local/libexec/dwm/dmenumount
index 08e27f49..1c3e1675 100755
--- a/.local/bin/mounter
+++ b/.local/libexec/dwm/dmenumount
@@ -12,13 +12,13 @@ IFS='
 escape() { echo "$@" | iconv -cf UTF-8 -t ASCII//TRANSLIT | tr -d '[:punct:]' | tr '[:upper:]' '[:lower:]' | tr ' ' '-' | sed "s/-\+/-/g;s/\(^-\|-\$\)//g"; }
 
 # Check for phones.
-phones="$(simple-mtpfs -l 2>/dev/null | sed "s/^/📱/")"
+phones="$(simple-mtpfs -l 2>/dev/null | sed "s/^/ /")"
 mountedphones="$(grep "simple-mtpfs" /etc/mtab)"
 # If there are already mounted phones, remove them from the list of mountables.
 [ -n "$mountedphones" ] && phones="$(for phone in $phones; do
 	for mounted in $mountedphones; do
 		escphone="$(escape "$phone")"
-		[[ "$mounted" =~ "$escphone" ]] && break 1
+		[[ "$mounted" =~ $escphone ]] && break 1
 	done && continue 1
 	echo "$phone"
 done)"
@@ -28,7 +28,7 @@ lsblkoutput="$(lsblk -rpo "uuid,name,type,size,label,mountpoint,fstype")"
 # Get all LUKS drives
 allluks="$(echo "$lsblkoutput" | grep crypto_LUKS)"
 # Get a list of the LUKS drive UUIDs already decrypted.
-decrypted="$(find /dev/disk/by-id/dm-uuid-CRYPT-LUKS2-* | sed "s|.*LUKS2-||;s|-.*||")"
+decrypted="$(find /dev/disk/by-id/dm-uuid-CRYPT-LUKS2-* 2>/dev/null | sed "s|.*LUKS2-||;s|-.*||")"
 # Functioning for formatting drives correctly for dmenu:
 filter() { sed "s/ /:/g" | awk -F':' '$7==""{printf "%s%s (%s) %s\n",$1,$3,$5,$6}'; }
 
@@ -39,11 +39,11 @@ unopenedluks="$(for drive in $allluks; do
 	[ -n "$decrypted" ] && for open in $decrypted; do
 		[ "$uuid" = "$open" ] && break 1
 	done && continue 1
-	echo "🔒 $drive"
+	echo " $drive"
 done | filter)"
 
 # Get all normal, non-encrypted or decrypted partitions that are not mounted.
-normalparts="$(echo "$lsblkoutput" | grep -v crypto_LUKS | grep 'part\|rom\|crypt' | sed "s/^/💾 /" | filter)"
+normalparts="$(echo "$lsblkoutput" | grep -v crypto_LUKS | grep 'part\|rom\|crypt' | sed "s/^/ /" | filter)"
 
 # Add all to one variable. If no mountable drives found, exit.
 alldrives="$(echo "$phones
@@ -71,20 +71,20 @@ getmount() {
 attemptmount() {
 	# Attempt to mount without a mountpoint, to see if drive is in fstab.
 	sudo -A mount "$chosen" || return 1
-	notify-send "💾Drive Mounted." "$chosen mounted."
+	notify-send " Drive Mounted." "$chosen mounted."
 	exit
 }
 
 case "$chosen" in
-💾*)
+*)
 	chosen="${chosen%% *}"
 	chosen="${chosen:1}" # This is a bashism.
 	attemptmount || getmount
 	sudo -A mount "$chosen" "$mp" -o uid="$(id -u)",gid="$(id -g)"
-	notify-send "💾Drive Mounted." "$chosen mounted to $mp."
+	notify-send " Drive Mounted." "$chosen mounted to $mp."
 	;;
 
-🔒*)
+*)
 	chosen="${chosen%% *}"
 	chosen="${chosen:1}" # This is a bashism.
 	# Number the drive.
@@ -100,15 +100,15 @@ case "$chosen" in
 
 	attemptmount || getmount
 	sudo -A mount "/dev/mapper/usb$num" "$mp" -o uid="$(id -u)",gid="$(id -g)"
-	notify-send "🔓Decrypted drive Mounted." "$chosen decrypted and mounted to $mp."
+	notify-send " Decrypted drive Mounted." "$chosen decrypted and mounted to $mp."
 	;;
 
-📱*)
+*)
 	notify-send "❗Note" "Remember to allow file access on your phone now."
 	getmount
 	number="${chosen%%:*}"
 	number="${chosen:1}" # This is a bashism.
 	sudo -A simple-mtpfs -o allow_other -o fsname="simple-mtpfs-$(escape "$chosen")" --device "$number" "$mp"
-	notify-send "🤖 Android Mounted." "Android device mounted to $mp."
+	notify-send " Android Mounted." "Android device mounted to $mp."
 	;;
 esac
diff --git a/.local/bin/dmenumountcifs b/.local/libexec/dwm/dmenumountcifs
similarity index 100%
rename from .local/bin/dmenumountcifs
rename to .local/libexec/dwm/dmenumountcifs
diff --git a/.local/bin/dmenupass b/.local/libexec/dwm/dmenupass
similarity index 100%
rename from .local/bin/dmenupass
rename to .local/libexec/dwm/dmenupass
diff --git a/.local/bin/dmenurecord b/.local/libexec/dwm/dmenurecord
similarity index 100%
rename from .local/bin/dmenurecord
rename to .local/libexec/dwm/dmenurecord
diff --git a/.local/libexec/dmenusys b/.local/libexec/dwm/dmenusys
similarity index 100%
rename from .local/libexec/dmenusys
rename to .local/libexec/dwm/dmenusys
diff --git a/.local/bin/dmenuumount b/.local/libexec/dwm/dmenuumount
similarity index 100%
rename from .local/bin/dmenuumount
rename to .local/libexec/dwm/dmenuumount
diff --git a/.local/bin/dmenuunicode b/.local/libexec/dwm/dmenuunicode
similarity index 100%
rename from .local/bin/dmenuunicode
rename to .local/libexec/dwm/dmenuunicode
diff --git a/.local/bin/pamixer-notify b/.local/libexec/dwm/pamixer-notify
similarity index 100%
rename from .local/bin/pamixer-notify
rename to .local/libexec/dwm/pamixer-notify
diff --git a/.local/bin/togcom b/.local/libexec/dwm/togcom
similarity index 100%
rename from .local/bin/togcom
rename to .local/libexec/dwm/togcom
diff --git a/.local/bin/togtp b/.local/libexec/dwm/togtp
similarity index 100%
rename from .local/bin/togtp
rename to .local/libexec/dwm/togtp
diff --git a/.local/libexec/statusbar/sb-battery b/.local/libexec/statusbar/sb-battery
index dcf9f9a1..ec318f82 100755
--- a/.local/libexec/statusbar/sb-battery
+++ b/.local/libexec/statusbar/sb-battery
@@ -9,7 +9,7 @@ reset="\033[0m"
 [ -z "$(ls /sys/class/power_supply)" ] && exit 0
 
 for battery in /sys/class/power_supply/BAT?*; do
-	pidof -x sbd-battery >/dev/null 2>&1 || sbd-battery "$battery" >/dev/null 2>&1 &
+	pidof -x sbd-battery >/dev/null 2>&1 || "$HOME/.local/libexec/daemons/sbd-battery" "$battery" >/dev/null 2>&1 &
 	[ -n "${capacity+x}" ] && printf " "
 	capacity="$(cat "$battery/capacity" 2>&1)"
 	case "$(cat "$battery/status" 2>&1)" in
diff --git a/.local/libexec/statusbar/sb-cpu b/.local/libexec/statusbar/sb-cpu
index 00784c12..6db12090 100755
--- a/.local/libexec/statusbar/sb-cpu
+++ b/.local/libexec/statusbar/sb-cpu
@@ -20,7 +20,7 @@ echo "$stats" | while read -r row; do
 	total=${rest%% *}
 	idle=${rest##* }
 	case "$(echo "$old" | awk '{if ($1 == id)
-		printf "%d\n", (1 - (idle - $3)  / (total - $2))*100 /12.5}' \
+		printf "%d\n", (1 - (idle - $3)  / (total - $2))*100 /12.5}' 2>/dev/null\
 		id="$id" total="$total" idle="$idle")" in
 	"0") printf "%b" "$green▁" ;;
 	"1") printf "%b" "$green▂" ;;
diff --git a/.local/libexec/statusbar/sb-music b/.local/libexec/statusbar/sb-music
index d3f47d9e..848f6d0a 100755
--- a/.local/libexec/statusbar/sb-music
+++ b/.local/libexec/statusbar/sb-music
@@ -11,5 +11,5 @@ filter() {
 		exit 1
 	fi
 }
-pidof -x sbd-music >/dev/null 2>&1 || sbd-music >/dev/null 2>&1 &
+pidof -x sbd-music >/dev/null 2>&1 || "$HOME/.local/libexec/daemons/sbd-music" >/dev/null 2>&1 &
 filter
diff --git a/.local/libexec/statusbar/sb-playerctl b/.local/libexec/statusbar/sb-playerctl
index 6765808a..8086ecd6 100755
--- a/.local/libexec/statusbar/sb-playerctl
+++ b/.local/libexec/statusbar/sb-playerctl
@@ -3,7 +3,7 @@
 big="\033[11m"
 reset="\033[0m"
 
-pidof -x sbd-playerctl >/dev/null 2>&1 || sbd-playerctl >/dev/null 2>&1 &
+pidof -x sbd-playerctl >/dev/null 2>&1 || "$HOME/.local/libexec/daemons/sbd-playerctl" >/dev/null 2>&1 &
 [ "$(playerctl status 2>&1)" = "No players found" ] && printf "%b%b" "$big" "$reset" && exit 1
 # song="$(playerctl metadata xesam:artist) - $(playerctl metadata xesam:title)"
 song="$(playerctl metadata xesam:title) - $(playerctl metadata xesam:artist)"