summaryrefslogtreecommitdiffstats
path: root/.local
diff options
context:
space:
mode:
Diffstat (limited to '.local')
-rwxr-xr-x.local/bin/ext3
-rwxr-xr-x.local/bin/samedir6
-rwxr-xr-x.local/bin/statusbar/battery10
-rwxr-xr-x.local/bin/statusbar/pacpackages16
-rwxr-xr-x.local/bin/statusbar/weather6
5 files changed, 28 insertions, 13 deletions
diff --git a/.local/bin/ext b/.local/bin/ext
index c2e0f5c..c5f89c5 100755
--- a/.local/bin/ext
+++ b/.local/bin/ext
@@ -24,7 +24,8 @@ fi
if [ -f "$archive" ] ; then
case "$archive" in
- *.tar.bz2|*.tar.xz|*.tbz2) tar xvjf "$archive" ;;
+ *.tar.bz2|*.tbz2) tar xvjf "$archive" ;;
+ *.tar.xz) tar -xf "$archive" ;;
*.tar.gz|*.tgz) tar xvzf "$archive" ;;
*.lzma) unlzma "$archive" ;;
*.bz2) bunzip2 "$archive" ;;
diff --git a/.local/bin/samedir b/.local/bin/samedir
index 740dcfc..73facfd 100755
--- a/.local/bin/samedir
+++ b/.local/bin/samedir
@@ -1,6 +1,8 @@
#!/bin/sh
+# Open a terminal window in the same directory as the currently active window.
+
PID=$(xprop -id "$(xprop -root | awk '/_NET_ACTIVE_WINDOW\(WINDOW\)/{print $NF}')" | grep -m 1 PID | cut -d " " -f 3)
-PID=$(echo "$(pstree -lpA "$PID" | tail -n 1)" | awk -F'---' '{print $NF}' | sed -re 's/[^0-9]//g')
-cd "$(readlink /proc/"$PID"/cwd)"
+PID="$(pstree -lpA "$PID" | tail -n 1 | awk -F'---' '{print $NF}' | sed -re 's/[^0-9]//g')"
+cd "$(readlink /proc/"$PID"/cwd)" || return 1
"$TERMINAL"
diff --git a/.local/bin/statusbar/battery b/.local/bin/statusbar/battery
index d9506f0..e8b0554 100755
--- a/.local/bin/statusbar/battery
+++ b/.local/bin/statusbar/battery
@@ -11,8 +11,10 @@ case $BLOCK_BUTTON in
- Text color reflects charge left" ;;
esac
-capacity=$(cat /sys/class/power_supply/"$1"/capacity) || exit
-status=$(cat /sys/class/power_supply/"$1"/status)
+for battery in /sys/class/power_supply/BAT?
+do
+capacity=$(cat "$battery"/capacity) || exit
+status=$(cat "$battery"/status)
if [ "$capacity" -ge 75 ]; then
color="#00ff00"
@@ -29,4 +31,6 @@ fi
[ "$status" = "Charging" ] && color="#ffffff"
-printf "<span color='%s'>%s%s%s</span>\n" "$color" "$(echo "$status" | sed -e "s/,//;s/Discharging/🔋/;s/Not charging/🛑/;s/Charging/🔌/;s/Unknown/♻️/;s/Full/⚡/;s/ 0*/ /g;s/ :/ /g")" "$warn" "$(echo "$capacity" | sed -e 's/$/%/')"
+printf "%s%s%s\n" "$(echo "$status" | sed "s/,//;s/Discharging/🔋/;s/Not charging/🛑/;s/Charging/🔌/;s/Unknown/♻️/;s/Full/⚡/;s/ 0*/ /g;s/ :/ /g")" "$warn" "$(echo "$capacity" | sed -e 's/$/%/')"
+done
+
diff --git a/.local/bin/statusbar/pacpackages b/.local/bin/statusbar/pacpackages
index 418bc2d..4273c86 100755
--- a/.local/bin/statusbar/pacpackages
+++ b/.local/bin/statusbar/pacpackages
@@ -1,10 +1,21 @@
#!/bin/sh
-# i3blocks module for pacman upgrades.
# Displays number of upgradeable packages.
# For this to work, have a `pacman -Sy` command run in the background as a
# cronjob every so often as root. This script will then read those packages.
# When clicked, it will run an upgrade via pacman.
+#
+# Add the following text as a file in /usr/share/libalpm/hooks/statusbar.hook:
+#
+# [Trigger]
+# Operation = Upgrade
+# Type = Package
+# Target = *
+#
+# [Action]
+# Description = Updating statusbar...
+# When = PostTransaction
+# Exec = /usr/bin/pkill -RTMIN+8 dwmblocks
case $BLOCK_BUTTON in
1) $TERMINAL -e popupgrade ;;
@@ -14,5 +25,4 @@ case $BLOCK_BUTTON in
- Middle click to show upgradable packages" ;;
esac
-
-pacman -Qu | grep -v "\[ignored\]" | wc -l | sed -e "s/^0$//g"
+pacman -Qu | grep -v "\[ignored\]" | wc -l | sed "s/^/📦/;s/^📦0$//g"
diff --git a/.local/bin/statusbar/weather b/.local/bin/statusbar/weather
index 4a11673..dc33cb9 100755
--- a/.local/bin/statusbar/weather
+++ b/.local/bin/statusbar/weather
@@ -1,12 +1,10 @@
#!/bin/sh
-location="$1"; [ -z "$location" ] || { location="$location+" && rm -f "$HOME/.local/share/weatherreport" ;}
-
getforecast() { ping -q -c 1 1.1.1.1 >/dev/null || exit 1
-curl -s "wttr.in/$location" > "$HOME/.local/share/weatherreport" || exit 1 ;}
+curl -sf "wttr.in/$LOCATION" > "$HOME/.local/share/weatherreport" || exit 1 ;}
showweather() { printf "%s" "$(sed '16q;d' "$HOME/.local/share/weatherreport" | grep -wo "[0-9]*%" | sort -n | sed -e '$!d' | sed -e "s/^/☔ /g" | tr -d '\n')"
-sed '13q;d' "$HOME/.local/share/weatherreport" | grep -o "m\\(-\\)*[0-9]\\+" | sort -n -t 'm' -k 2n | sed -e 1b -e '$!d' | tr '\n|m' ' ' | awk '{print " ❄️",$1 "°","🌞",$2 "°"}' ;}
+sed '13q;d' "$HOME/.local/share/weatherreport" | grep -o "m\\(-+\\)*[0-9]\\+" | sort -n -t 'm' -k 2n | sed -e 1b -e '$!d' | tr '\n|m' ' ' | awk '{print " ❄️",$1 "°","🌞",$2 "°"}' ;}
case $BLOCK_BUTTON in
1) $TERMINAL -e less -S "$HOME/.local/share/weatherreport" ;;