diff options
Diffstat (limited to '.local/bin')
| -rwxr-xr-x | .local/bin/cron/cronbat | 9 | ||||
| -rwxr-xr-x | .local/bin/dmenuunicode | 2 | ||||
| -rwxr-xr-x | .local/bin/ext | 1 | ||||
| -rwxr-xr-x | .local/bin/statusbar/sb-battery | 15 | ||||
| -rwxr-xr-x | .local/bin/statusbar/sb-crypto | 54 | ||||
| -rwxr-xr-x | .local/bin/statusbar/sb-forecast | 2 | ||||
| -rwxr-xr-x | .local/bin/statusbar/sb-price | 2 | ||||
| -rwxr-xr-x | .local/bin/sysact | 3 |
8 files changed, 12 insertions, 76 deletions
diff --git a/.local/bin/cron/cronbat b/.local/bin/cron/cronbat deleted file mode 100755 index bd953c7..0000000 --- a/.local/bin/cron/cronbat +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/sh - -# Notify me with notify-send if my battery is below 25%. -# You can set this to run via cron. - -[ "$(cat /sys/class/power_supply/BAT0/status)" = "Charging" ] && exit -[ "$(cat /sys/class/power_supply/BAT0/capacity)" -lt 25 ] && -export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/$(id -u $USER)/bus && -notify-send -u critical "Battery critically low." diff --git a/.local/bin/dmenuunicode b/.local/bin/dmenuunicode index de1421b..7d9a4ea 100755 --- a/.local/bin/dmenuunicode +++ b/.local/bin/dmenuunicode @@ -13,6 +13,6 @@ chosen=$(cut -d ';' -f1 ~/.local/share/larbs/emoji | dmenu -i -l 30 | sed "s/ .* if [ -n "$1" ]; then xdotool type "$chosen" else - echo "$chosen" | tr -d '\n' | xclip -selection clipboard + printf "$chosen" | xclip -selection clipboard notify-send "'$chosen' copied to clipboard." & fi diff --git a/.local/bin/ext b/.local/bin/ext index 806ce5e..927fb5b 100755 --- a/.local/bin/ext +++ b/.local/bin/ext @@ -27,6 +27,7 @@ if [ -f "$archive" ] ; then *.tar.bz2|*.tbz2) tar xvjf "$archive" ;; *.tar.xz) tar -xf "$archive" ;; *.tar.gz|*.tgz) tar xvzf "$archive" ;; + *.tar.zst) tar -I zstd -xf "$archive" ;; *.lzma) unlzma "$archive" ;; *.bz2) bunzip2 "$archive" ;; *.rar) unrar x -ad "$archive" ;; diff --git a/.local/bin/statusbar/sb-battery b/.local/bin/statusbar/sb-battery index d0272ec..382b31b 100755 --- a/.local/bin/statusbar/sb-battery +++ b/.local/bin/statusbar/sb-battery @@ -16,15 +16,12 @@ case $BLOCK_BUTTON in 6) "$TERMINAL" -e "$EDITOR" "$0" ;; esac -# Check if battery directories are detected -[ ! -e /sys/class/power_supply/BAT?* ] && echo "No battery found" && exit 1 - # Loop through all attached batteries and format the info -for battery in /sys/class/power_supply/BAT?* -do +for battery in /sys/class/power_supply/BAT?*; do + # If non-first battery, print a space separator. + [ -n "${capacity+x}" ] && printf " " # Sets up the status and capacity - status=$(cat "$battery/status") - case "$status" in + case "$(cat "$battery/status")" in "Full") status="⚡" ;; "Discharging") status="🔋" ;; "Charging") status="🔌" ;; @@ -35,5 +32,5 @@ do # Will make a warn variable if discharging and low [ "$status" = "🔋" ] && [ "$capacity" -le 25 ] && warn="❗" # Prints the info - printf "%s%s%d%%\n" "$status" "$warn" "$capacity"; unset warn -done && return 0 + printf "%s%s%d%%" "$status" "$warn" "$capacity"; unset warn +done && exit 0 diff --git a/.local/bin/statusbar/sb-crypto b/.local/bin/statusbar/sb-crypto deleted file mode 100755 index 94ed949..0000000 --- a/.local/bin/statusbar/sb-crypto +++ /dev/null @@ -1,54 +0,0 @@ -#!/bin/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;📚" - -# 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 - info="$(cut -d';' -f-2 --output-delimiter=' ' "$x")" - printf "%s$%0.2f " "$info" - 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 example.org >/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"/*) -<b>Last updated:</b> - $uptime" ;; - 2) getprices ;; - 3) 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/.local/bin/statusbar/sb-forecast b/.local/bin/statusbar/sb-forecast index 6652edd..7b8416e 100755 --- a/.local/bin/statusbar/sb-forecast +++ b/.local/bin/statusbar/sb-forecast @@ -14,7 +14,7 @@ getforecast() { curl -sf "wttr.in/$LOCATION" > "$weatherreport" || exit 1 ;} # display them with coresponding emojis. showweather() { printf "%s" "$(sed '16q;d' "$weatherreport" | grep -wo "[0-9]*%" | sort -rn | sed "s/^/☔/g;1q" | tr -d '\n')" -sed '13q;d' "$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' "$weatherreport" | grep -o "m\\([-+]\\)*[0-9]\\+" | sed 's/+//g' | sort -n -t 'm' -k 2n | sed -e 1b -e '$!d' | tr '\n|m' ' ' | awk '{print " 🥶" $1 "°","🌞" $2 "°"}' ;} case $BLOCK_BUTTON in 1) setsid -f "$TERMINAL" -e less -Srf "$weatherreport" ;; diff --git a/.local/bin/statusbar/sb-price b/.local/bin/statusbar/sb-price index 45b01ad..35b072f 100755 --- a/.local/bin/statusbar/sb-price +++ b/.local/bin/statusbar/sb-price @@ -21,7 +21,7 @@ updateprice() { ping -q -c 1 example.org >/dev/null 2>&1 && updateprice "$1" case $BLOCK_BUTTON in - 1) setsid "$TERMINAL" -e less -Sf "$chartfile" ;; + 1) setsid "$TERMINAL" -e less -Srf "$chartfile" ;; 2) notify-send -u low "$3 Updating..." "Updating $2 price..." updateprice "$1" && notify-send "$3 Update complete." "$2 price is now \$$(cat "$pricefile")" ;; diff --git a/.local/bin/sysact b/.local/bin/sysact index 9dc398b..62fdd61 100755 --- a/.local/bin/sysact +++ b/.local/bin/sysact @@ -14,7 +14,8 @@ cmds="\ ♻ renew dwm kill -HUP $(pgrep -u $USER "\bdwm$") 🐻 hibernate slock ${hib:-systemctl suspend-then-hibernate -i} 🔃 reboot ${reb:-sudo -A reboot} -🖥 shutdown ${shut:-sudo -A shutdown -h now}" +🖥 shutdown ${shut:-sudo -A shutdown -h now} +📺 display off xset dpms force off" choice="$(echo "$cmds" | cut -d' ' -f 1 | dmenu)" || exit 1 |
