From 49f19f0bd75bd4239fee9136d55b958dfb0b76fa Mon Sep 17 00:00:00 2001 From: altffour Date: Tue, 15 Dec 2020 08:48:57 +0300 Subject: [PATCH] add lukesmith's statusbar stuff and some other local binaries --- .local/bin/f2py | 8 +++++ .local/bin/f2py3 | 8 +++++ .local/bin/f2py3.8 | 8 +++++ .local/bin/genzathurarc | 1 + .local/bin/protonvpn | 8 +++++ .local/bin/statusbar/battery | 34 ++++++++++++++++++++ .local/bin/statusbar/clock | 29 +++++++++++++++++ .local/bin/statusbar/cpu | 12 +++++++ .local/bin/statusbar/cpubars | 44 ++++++++++++++++++++++++++ .local/bin/statusbar/crypto | 54 ++++++++++++++++++++++++++++++++ .local/bin/statusbar/disk | 23 ++++++++++++++ .local/bin/statusbar/forecast | 35 +++++++++++++++++++++ .local/bin/statusbar/help-icon | 17 ++++++++++ .local/bin/statusbar/internet | 24 ++++++++++++++ .local/bin/statusbar/iplocate | 10 ++++++ .local/bin/statusbar/kbselect | 16 ++++++++++ .local/bin/statusbar/mailbox | 20 ++++++++++++ .local/bin/statusbar/memory | 12 +++++++ .local/bin/statusbar/moonphase | 37 ++++++++++++++++++++++ .local/bin/statusbar/mpdup | 8 +++++ .local/bin/statusbar/music | 19 +++++++++++ .local/bin/statusbar/nettraf | 29 +++++++++++++++++ .local/bin/statusbar/news | 17 ++++++++++ .local/bin/statusbar/pacpackages | 29 +++++++++++++++++ .local/bin/statusbar/popupgrade | 9 ++++++ .local/bin/statusbar/price | 38 ++++++++++++++++++++++ .local/bin/statusbar/torrent | 27 ++++++++++++++++ .local/bin/statusbar/volume | 28 +++++++++++++++++ .local/bin/yapf | 8 +++++ .local/bin/zathura | 1 + 30 files changed, 613 insertions(+) create mode 100755 .local/bin/f2py create mode 100755 .local/bin/f2py3 create mode 100755 .local/bin/f2py3.8 create mode 120000 .local/bin/genzathurarc create mode 100755 .local/bin/protonvpn create mode 100755 .local/bin/statusbar/battery create mode 100755 .local/bin/statusbar/clock create mode 100755 .local/bin/statusbar/cpu create mode 100755 .local/bin/statusbar/cpubars create mode 100755 .local/bin/statusbar/crypto create mode 100755 .local/bin/statusbar/disk create mode 100755 .local/bin/statusbar/forecast create mode 100755 .local/bin/statusbar/help-icon create mode 100755 .local/bin/statusbar/internet create mode 100755 .local/bin/statusbar/iplocate create mode 100755 .local/bin/statusbar/kbselect create mode 100755 .local/bin/statusbar/mailbox create mode 100755 .local/bin/statusbar/memory create mode 100755 .local/bin/statusbar/moonphase create mode 100755 .local/bin/statusbar/mpdup create mode 100755 .local/bin/statusbar/music create mode 100755 .local/bin/statusbar/nettraf create mode 100755 .local/bin/statusbar/news create mode 100755 .local/bin/statusbar/pacpackages create mode 100755 .local/bin/statusbar/popupgrade create mode 100755 .local/bin/statusbar/price create mode 100755 .local/bin/statusbar/torrent create mode 100755 .local/bin/statusbar/volume create mode 100755 .local/bin/yapf create mode 120000 .local/bin/zathura diff --git a/.local/bin/f2py b/.local/bin/f2py new file mode 100755 index 0000000..40ce6f8 --- /dev/null +++ b/.local/bin/f2py @@ -0,0 +1,8 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +import re +import sys +from numpy.f2py.f2py2e import main +if __name__ == '__main__': + sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) + sys.exit(main()) diff --git a/.local/bin/f2py3 b/.local/bin/f2py3 new file mode 100755 index 0000000..40ce6f8 --- /dev/null +++ b/.local/bin/f2py3 @@ -0,0 +1,8 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +import re +import sys +from numpy.f2py.f2py2e import main +if __name__ == '__main__': + sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) + sys.exit(main()) diff --git a/.local/bin/f2py3.8 b/.local/bin/f2py3.8 new file mode 100755 index 0000000..40ce6f8 --- /dev/null +++ b/.local/bin/f2py3.8 @@ -0,0 +1,8 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +import re +import sys +from numpy.f2py.f2py2e import main +if __name__ == '__main__': + sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) + sys.exit(main()) diff --git a/.local/bin/genzathurarc b/.local/bin/genzathurarc new file mode 120000 index 0000000..aa1ab82 --- /dev/null +++ b/.local/bin/genzathurarc @@ -0,0 +1 @@ +/home/dizzy/dox/opt/Zathura-Pywal/genzathurarc \ No newline at end of file diff --git a/.local/bin/protonvpn b/.local/bin/protonvpn new file mode 100755 index 0000000..accab50 --- /dev/null +++ b/.local/bin/protonvpn @@ -0,0 +1,8 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +import re +import sys +from protonvpn_cli.cli import main +if __name__ == '__main__': + sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) + sys.exit(main()) diff --git a/.local/bin/statusbar/battery b/.local/bin/statusbar/battery new file mode 100755 index 0000000..f42d096 --- /dev/null +++ b/.local/bin/statusbar/battery @@ -0,0 +1,34 @@ +#!/bin/sh + +# Prints all batteries, their percentage remaining and an emoji corresponding +# to charge status (🔌 for plugged up, 🔋 for discharging on battery, etc.). + +case $BLOCK_BUTTON in + 3) notify-send "🔋 Battery module" "🔋: discharging +🛑: not charging +♻: stagnant charge +🔌: charging +⚡: charged +❗: battery very low! +- Scroll to change adjust xbacklight." ;; + 4) xbacklight -inc 10 ;; + 5) xbacklight -dec 10 ;; + 6) "$TERMINAL" -e "$EDITOR" "$0" ;; +esac + +# acpi alternative +# acpi | sed "s/Battery [0-9]: //;s/[Dd]ischarging, /🔋/;s/[Nn]ot charging, /🛑/;s/[Cc]harging, /🔌/;s/[Uu]nknown, /♻️/;s/[Ff]ull, /⚡/;s/ \(remaining\|until charged\)//"; exit + +# Loop through all attached batteries. +for battery in /sys/class/power_supply/BAT? +do + # Get its remaining capacity and charge status. + capacity=$(cat "$battery"/capacity 2>/dev/null) || break + status=$(sed "s/[Dd]ischarging/🔋/;s/[Nn]ot charging/🛑/;s/[Cc]harging/🔌/;s/[Uu]nknown/♻️/;s/[Ff]ull/⚡/" "$battery"/status) + + # If it is discharging and 25% or less, we will add a ❗ as a warning. + [ "$capacity" -le 25 ] && [ "$status" = "🔋" ] && warn="❗" + + printf "%s%s%s%% " "$status" "$warn" "$capacity" + unset warn +done | sed 's/ *$//' diff --git a/.local/bin/statusbar/clock b/.local/bin/statusbar/clock new file mode 100755 index 0000000..d25e8d0 --- /dev/null +++ b/.local/bin/statusbar/clock @@ -0,0 +1,29 @@ +#!/bin/sh + +clock=$(date '+%I') + +case "$clock" in + "00") icon="🕛" ;; + "01") icon="🕐" ;; + "02") icon="🕑" ;; + "03") icon="🕒" ;; + "04") icon="🕓" ;; + "05") icon="🕔" ;; + "06") icon="🕕" ;; + "07") icon="🕖" ;; + "08") icon="🕗" ;; + "09") icon="🕘" ;; + "10") icon="🕙" ;; + "11") icon="🕚" ;; + "12") icon="🕛" ;; +esac + +case $BLOCK_BUTTON in + 1) notify-send "This Month" "$(cal --color=always | sed "s/..7m//;s/..27m/<\/span><\/b>/")" && notify-send "Appointments" "$(calcurse -d3)" ;; + 2) setsid -f "$TERMINAL" -e calcurse ;; + 3) notify-send "📅 Time/date module" "\- Left click to show upcoming appointments for the next three days via \`calcurse -d3\` and show the month via \`cal\` +- Middle click opens calcurse if installed" ;; + 6) "$TERMINAL" -e "$EDITOR" "$0" ;; +esac + +date "+%Y %b %d (%a) $icon%I:%M%p" diff --git a/.local/bin/statusbar/cpu b/.local/bin/statusbar/cpu new file mode 100755 index 0000000..1572b52 --- /dev/null +++ b/.local/bin/statusbar/cpu @@ -0,0 +1,12 @@ +#!/bin/sh + +case $BLOCK_BUTTON in + 1) notify-send "🖥 CPU hogs" "$(ps axch -o cmd:15,%cpu --sort=-%cpu | head)\\n(100% per core)" ;; + 2) setsid -f "$TERMINAL" -e htop ;; + 3) notify-send "🖥 CPU module " "\- Shows CPU temperature. +- Click to show intensive processes. +- Middle click to open htop." ;; + 6) "$TERMINAL" -e "$EDITOR" "$0" ;; +esac + +sensors | awk '/Core 0/ {print "🌡" $3}' diff --git a/.local/bin/statusbar/cpubars b/.local/bin/statusbar/cpubars new file mode 100755 index 0000000..297424e --- /dev/null +++ b/.local/bin/statusbar/cpubars @@ -0,0 +1,44 @@ +#!/bin/sh + +# Module showing CPU load as a changing bars. +# Just like in polybar. +# Each bar represents amount of load on one core since +# last run. + +# Cache in tmpfs to improve speed and reduce SSD load +cache=/tmp/cpubarscache + +case $BLOCK_BUTTON in + 2) setsid -f "$TERMINAL" -e htop ;; + 3) notify-send "🪨 CPU load module" "Each bar represents +one CPU core";; + 6) "$TERMINAL" -e "$EDITOR" "$0" ;; +esac + +# id total idle +stats=$(awk '/cpu[0-9]+/ {printf "%d %d %d\n", substr($1,4), ($2 + $3 + $4 + $5), $5 }' /proc/stat) +[ ! -f $cache ] && echo "$stats" > "$cache" +old=$(cat "$cache") +printf "🪨" +echo "$stats" | while read -r row; do + id=${row%% *} + rest=${row#* } + total=${rest%% *} + idle=${rest##* } + + case "$(echo "$old" | awk '{if ($1 == id) + printf "%d\n", (1 - (idle - $3) / (total - $2))*100 /12.5}' \ + id="$id" total="$total" idle="$idle")" in + + "0") printf "▁";; + "1") printf "▂";; + "2") printf "▃";; + "3") printf "▄";; + "4") printf "▅";; + "5") printf "▆";; + "6") printf "▇";; + "7") printf "█";; + "8") printf "█";; + esac +done; printf "\\n" +echo "$stats" > "$cache" diff --git a/.local/bin/statusbar/crypto b/.local/bin/statusbar/crypto new file mode 100755 index 0000000..94ed949 --- /dev/null +++ b/.local/bin/statusbar/crypto @@ -0,0 +1,54 @@ +#!/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"/*) +Last updated: + $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/disk b/.local/bin/statusbar/disk new file mode 100755 index 0000000..e947509 --- /dev/null +++ b/.local/bin/statusbar/disk @@ -0,0 +1,23 @@ +#!/bin/sh + +# Status bar module for disk space +# $1 should be drive mountpoint, otherwise assumed /. + +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="🏠" ;; + "/mnt"* ) icon="💾" ;; + *) icon="🖥";; +esac + +printf "%s: %s\n" "$icon" "$(df -h "$location" | awk ' /[0-9]/ {print $3 "/" $2}')" diff --git a/.local/bin/statusbar/forecast b/.local/bin/statusbar/forecast new file mode 100755 index 0000000..6652edd --- /dev/null +++ b/.local/bin/statusbar/forecast @@ -0,0 +1,35 @@ +#!/bin/sh + +# Displays todays precipication chance (☔) and daily low (🥶) and high (🌞). +# Usually intended for the statusbar. + +# If we have internet, get a weather report from wttr.in and store it locally. +# You could set up a shell alias to view the full file in a pager in the +# terminal if desired. This function will only be run once a day when needed. +weatherreport="${XDG_DATA_HOME:-$HOME/.local/share}/weatherreport" +getforecast() { curl -sf "wttr.in/$LOCATION" > "$weatherreport" || exit 1 ;} + +# Some very particular and terse stream manipulation. We get the maximum +# precipitation chance and the daily high and low from the downloaded file and +# 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 "°"}' ;} + +case $BLOCK_BUTTON in + 1) setsid -f "$TERMINAL" -e less -Srf "$weatherreport" ;; + 2) getforecast && showweather ;; + 3) notify-send "🌈 Weather module" "\- Left click for full forecast. +- Middle click to update forecast. +☔: Chance of rain/snow +🥶: Daily low +🌞: Daily high" ;; + 6) "$TERMINAL" -e "$EDITOR" "$0" ;; +esac + +# The test if our forcecast is updated to the day. If it isn't download a new +# weather report from wttr.in with the above function. +[ "$(stat -c %y "$weatherreport" 2>/dev/null | cut -d' ' -f1)" = "$(date '+%Y-%m-%d')" ] || + getforecast + +showweather diff --git a/.local/bin/statusbar/help-icon b/.local/bin/statusbar/help-icon new file mode 100755 index 0000000..8fa4a52 --- /dev/null +++ b/.local/bin/statusbar/help-icon @@ -0,0 +1,17 @@ +#!/bin/sh + +# The clickable help menu. Middle click to restart wm. + +# If dwm is running, use dwm's readme and restart. +pidof dwm >/dev/null && + READMEFILE=/usr/local/share/dwm/larbs.mom + restartwm() { pkill -HUP dwm ;} || + restartwm() { i3 restart ;} + +case $BLOCK_BUTTON in + 1) groff -mom "${READMEFILE:-${XDG_DATA_HOME:-$HOME/.local/share}/larbs/readme.mom}" -Tpdf | zathura - ;; + 2) restartwm ;; + 3) notify-send "❓ Help module" "\- Left click to open LARBS guide. +- Middle click to refresh window manager." ;; + 6) "$TERMINAL" -e "$EDITOR" "$0" ;; +esac; echo "❓" diff --git a/.local/bin/statusbar/internet b/.local/bin/statusbar/internet new file mode 100755 index 0000000..ee1a160 --- /dev/null +++ b/.local/bin/statusbar/internet @@ -0,0 +1,24 @@ +#!/bin/sh + +# Show wifi 📶 and percent strength or 📡 if none. +# Show 🌐 if connected to ethernet or ❎ if none. +# Show 🔒 if a vpn connection is active + +case $BLOCK_BUTTON in + 1) "$TERMINAL" -e nmtui; pkill -RTMIN+4 dwmblocks ;; + 3) notify-send "🌐 Internet module" "\- Click to connect +📡: no wifi connection +📶: wifi connection with quality +❎: no ethernet +🌐: ethernet working +🔒: vpn is active +" ;; + 6) "$TERMINAL" -e "$EDITOR" "$0" ;; +esac + +case "$(cat /sys/class/net/w*/operstate 2>/dev/null)" in + down) wifiicon="📡 " ;; + up) wifiicon="$(awk '/^\s*w/ { print "📶", int($3 * 100 / 70) "% " }' /proc/net/wireless)" ;; +esac + +printf "%s%s%s\n" "$wifiicon" "$(sed "s/down/❎/;s/up/🌐/" /sys/class/net/e*/operstate 2>/dev/null)" "$(sed "s/.*/🔒/" /sys/class/net/tun*/operstate 2>/dev/null)" diff --git a/.local/bin/statusbar/iplocate b/.local/bin/statusbar/iplocate new file mode 100755 index 0000000..02adab8 --- /dev/null +++ b/.local/bin/statusbar/iplocate @@ -0,0 +1,10 @@ +#!/bin/sh + +# Gets your public ip address checks which country you are in and +# displays that information in the statusbar +# +# https://www.maketecheasier.com/ip-address-geolocation-lookups-linux/ + +ifinstalled "geoip" || exit +addr="$(curl ifconfig.me 2>/dev/null)" || exit +grep "flag: " "${XDG_DATA_HOME:-$HOME/.local/share}/larbs/emoji" | grep "$(geoiplookup "$addr" | sed 's/.*, //')" | sed "s/flag: //;s/;.*//" diff --git a/.local/bin/statusbar/kbselect b/.local/bin/statusbar/kbselect new file mode 100755 index 0000000..f0c923f --- /dev/null +++ b/.local/bin/statusbar/kbselect @@ -0,0 +1,16 @@ +#!/bin/sh +# works on any init system +# requirements: dmenu, xorg-setxkbmap +kb="$(setxkbmap -query | grep -oP 'layout:\s*\K\w+')" || exit 1 + +case $BLOCK_BUTTON in + 1) kb_choice="$(awk '/! layout/{flag=1; next} /! variant/{flag=0} flag {print $2, "- " $1}' /usr/share/X11/xkb/rules/base.lst | dmenu -l 15)" + kb="$(echo "$kb_choice" | awk '{print $3}')" + setxkbmap "$kb" + pkill -RTMIN+30 "${STATUSBAR:-dwmblocks}";; + 3) notify-send "⌨ Keyboard/language module" "$(printf "%s" "\- Current layout: $(setxkbmap -query | grep -oP 'layout:\s*\K\w+')") +- Left click to change keyboard.";; + 6) "$TERMINAL" -e "$EDITOR" "$0" ;; +esac + +echo "$kb" diff --git a/.local/bin/statusbar/mailbox b/.local/bin/statusbar/mailbox new file mode 100755 index 0000000..5a67428 --- /dev/null +++ b/.local/bin/statusbar/mailbox @@ -0,0 +1,20 @@ +#!/bin/sh + +# Displays number of unread mail and an loading icon if updating. +# When clicked, brings up `neomutt`. + +case $BLOCK_BUTTON in + 1) setsid -f "$TERMINAL" -e neomutt ;; + 2) setsid -f mw sync >/dev/null ;; + 3) notify-send "📬 Mail module" "\- Shows unread mail +- Shows 🔃 if syncing mail +- Left click opens neomutt +- Middle click syncs mail" ;; + 6) "$TERMINAL" -e "$EDITOR" "$0" ;; +esac + +unread="$(find "${XDG_DATA_HOME:-$HOME/.local/share}"/mail/*/[Ii][Nn][Bb][Oo][Xx]/new/* -type f | wc -l 2>/dev/null)" + +pidof mbsync >/dev/null 2>&1 && icon="🔃" + +[ "$unread" = "0" ] && [ "$icon" = "" ] || echo "📬$unread$icon" diff --git a/.local/bin/statusbar/memory b/.local/bin/statusbar/memory new file mode 100755 index 0000000..01d3daf --- /dev/null +++ b/.local/bin/statusbar/memory @@ -0,0 +1,12 @@ +#!/bin/sh + +case $BLOCK_BUTTON in + 1) notify-send "🧠 Memory hogs" "$(ps axch -o cmd:15,%mem --sort=-%mem | head)" ;; + 2) setsid -f "$TERMINAL" -e htop ;; + 3) notify-send "🧠 Memory module" "\- Shows Memory Used/Total. +- Click to show memory hogs. +- Middle click to open htop." ;; + 6) "$TERMINAL" -e "$EDITOR" "$0" ;; +esac + +free --mebi | sed -n '2{p;q}' | awk '{printf ("🧠%2.2fGiB/%2.2fGiB\n", ( $3 / 1024), ($2 / 1024))}' diff --git a/.local/bin/statusbar/moonphase b/.local/bin/statusbar/moonphase new file mode 100755 index 0000000..fab8b4d --- /dev/null +++ b/.local/bin/statusbar/moonphase @@ -0,0 +1,37 @@ +#!/bin/sh + +# Shows the current moon phase. + +moonfile="${XDG_DATA_HOME:-$HOME/.local/share}/moonphase" + +[ "$(stat -c %y "$moonfile" 2>/dev/null | cut -d' ' -f1)" = "$(date '+%Y-%m-%d')" ] || + { curl -sf "wttr.in/?format=%m" > "$moonfile" || exit 1 ;} + +icon="$(cat "$moonfile")" + +case "$icon" in + 🌑) name="New" ;; + 🌒) name="Waxing Crescent" ;; + 🌓) name="First Quarter" ;; + 🌔) name="Waxing Gibbous" ;; + 🌕) name="Full" ;; + 🌖) name="Waning Gibbous" ;; + 🌗) name="Last Quarter" ;; + 🌘) name="Waning Crescent" ;; + *) exit 1 ;; +esac + +echo "${icon-?}" + +case $BLOCK_BUTTON in + 3) notify-send "🌜 Moon phase module" "Displays current moon phase. +- 🌑: New +- 🌒: Waxing Crescent +- 🌓: First Quarter +- 🌔: Waxing Gibbous +- 🌕: Full +- 🌖: Waning Gibbous +- 🌗: Last Quarter +- 🌘: Waning Crescent" ;; + 6) "$TERMINAL" -e "$EDITOR" "$0" ;; +esac diff --git a/.local/bin/statusbar/mpdup b/.local/bin/statusbar/mpdup new file mode 100755 index 0000000..af81a7d --- /dev/null +++ b/.local/bin/statusbar/mpdup @@ -0,0 +1,8 @@ +#!/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. + +while : ; do + mpc idle >/dev/null && kill -45 "$(pidof "${STATUSBAR:-dwmblocks}")" || break +done diff --git a/.local/bin/statusbar/music b/.local/bin/statusbar/music new file mode 100755 index 0000000..4b7c115 --- /dev/null +++ b/.local/bin/statusbar/music @@ -0,0 +1,19 @@ +#!/bin/sh + +filter() { mpc | sed "/^volume:/d;s/\\&/&/g;s/\\[paused\\].*/⏸/g;/\\[playing\\].*/d" | paste -sd ' ' -;} + +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 ;; # right click, pause/unpause + 2) mpc toggle | filter ;; # right click, pause/unpause + 3) mpc status | filter ; notify-send "🎵 Music module" "\- Shows mpd song playing. +- ⏸ 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" ;; + *) mpc status | filter ;; +esac diff --git a/.local/bin/statusbar/nettraf b/.local/bin/statusbar/nettraf new file mode 100755 index 0000000..eb7a73b --- /dev/null +++ b/.local/bin/statusbar/nettraf @@ -0,0 +1,29 @@ +#!/bin/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 + 1) setsid -f "$TERMINAL" -e bmon ;; + 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 )) +} + +rx=$(update /sys/class/net/[ew]*/statistics/rx_bytes) +tx=$(update /sys/class/net/[ew]*/statistics/tx_bytes) + +printf "🔻%4sB 🔺%4sB\\n" $(numfmt --to=iec $rx) $(numfmt --to=iec $tx) diff --git a/.local/bin/statusbar/news b/.local/bin/statusbar/news new file mode 100755 index 0000000..fe701db --- /dev/null +++ b/.local/bin/statusbar/news @@ -0,0 +1,17 @@ +#!/bin/sh + +# Displays number of unread news items and an loading icon if updating. +# When clicked, brings up `newsboat`. + +case $BLOCK_BUTTON in + 1) setsid "$TERMINAL" -e newsboat ;; + 2) setsid -f newsup >/dev/null exit ;; + 3) notify-send "📰 News module" "\- Shows unread news items +- Shows 🔃 if updating with \`newsup\` +- Left click opens newsboat +- Middle click syncs RSS feeds +Note: Only one instance of newsboat (including updates) may be running at a time." ;; + 6) "$TERMINAL" -e "$EDITOR" "$0" ;; +esac + + cat /tmp/newsupdate 2>/dev/null || echo "$(newsboat -x print-unread | awk '{ if($1>0) print "📰" $1}')$(cat "${XDG_CONFIG_HOME:-$HOME/.config}"/newsboat/.update 2>/dev/null)" diff --git a/.local/bin/statusbar/pacpackages b/.local/bin/statusbar/pacpackages new file mode 100755 index 0000000..a9b6cf7 --- /dev/null +++ b/.local/bin/statusbar/pacpackages @@ -0,0 +1,29 @@ +#!/bin/sh + +# 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 # Or i3blocks if using i3. + +case $BLOCK_BUTTON in + 1) setsid -f "$TERMINAL" -e popupgrade ;; + 2) notify-send "$(/usr/bin/pacman -Qu)" ;; + 3) notify-send "🎁 Upgrade module" "📦: number of upgradable packages +- Left click to upgrade packages +- Middle click to show upgradable packages" ;; + 6) "$TERMINAL" -e "$EDITOR" "$0" ;; +esac + +pacman -Qu | grep -Fcv "[ignored]" | sed "s/^/📦/;s/^📦0$//g" diff --git a/.local/bin/statusbar/popupgrade b/.local/bin/statusbar/popupgrade new file mode 100755 index 0000000..29d6230 --- /dev/null +++ b/.local/bin/statusbar/popupgrade @@ -0,0 +1,9 @@ +#!/bin/sh + +printf "Beginning upgrade.\\n" + +yay -Syu +pkill -RTMIN+8 "${STATUSBAR:-dwmblocks}" + +printf "\\nUpgrade complete.\\nPress to exit window.\\n\\n" +read -r _ diff --git a/.local/bin/statusbar/price b/.local/bin/statusbar/price new file mode 100755 index 0000000..45b01ad --- /dev/null +++ b/.local/bin/statusbar/price @@ -0,0 +1,38 @@ +#!/bin/sh + +# Usage: +# price +# price bat "Basic Attention Token" 🦁 +# When the name of the currency is multi-word, put it in quotes. + +[ -z "$3" ] && exit 1 +interval="@14d" # History contained in chart preceded by '@' (7d = 7 days) +dir="${XDG_DATA_HOME:-$HOME/.local/share}/crypto-prices" +pricefile="$dir/$1" +chartfile="$dir/$1-chart" + +updateprice() { ping -q -c 1 example.org >/dev/null 2>&1 && + curl -s "rate.sx/1$1" > "$pricefile" && + curl -s "rate.sx/$1$interval" > "$chartfile" ;} + +[ -d "$dir" ] || mkdir -p "$dir" + +[ "$(stat -c %x "$pricefile" 2>/dev/null | cut -d' ' -f1)" != "$(date '+%Y-%m-%d')" ] && + updateprice "$1" + +case $BLOCK_BUTTON in + 1) setsid "$TERMINAL" -e less -Sf "$chartfile" ;; + 2) notify-send -u low "$3 Updating..." "Updating $2 price..." + updateprice "$1" && notify-send "$3 Update complete." "$2 price is now +\$$(cat "$pricefile")" ;; + 3) uptime="$(date -d "$(stat -c %x "$pricefile")" '+%D at %T' | sed "s|$(date '+%D')|Today|")" + notify-send "$3 $2 module" "\- Exact price: \$$(cat "$pricefile") +- Left click for chart of changes. +- Middle click to update. +- Shows 🔃 if updating prices. +- Last updated: + $uptime" ;; + 6) "$TERMINAL" -e "$EDITOR" "$0" ;; +esac + +printf "$3$%0.2f" "$(cat "$pricefile")" diff --git a/.local/bin/statusbar/torrent b/.local/bin/statusbar/torrent new file mode 100755 index 0000000..6527005 --- /dev/null +++ b/.local/bin/statusbar/torrent @@ -0,0 +1,27 @@ +#!/bin/sh + +transmission-remote -l | grep % | + sed " # The letters are for sorting and will not appear. + s/.*Stopped.*/A 🛑/; + s/.*Seeding.*/Z 🌱/; + s/.*100%.*/N ✅/; + s/.*Idle.*/B 🕰️/; + s/.*Uploading.*/L ⬆️/; + s/.*%.*/M ⬇️/" | + sort -h | uniq -c | awk '{print $3 $1}' | paste -sd ' ' - + +case $BLOCK_BUTTON in + 1) setsid -f "$TERMINAL" -e tremc ;; + 2) td-toggle ;; + 3) notify-send "🌱 Torrent module" "\- Left click to open tremc. +- Middle click to toggle transmission. +- Shift click to edit script. +Module shows number of torrents: +🛑: paused +🕰: idle (seeds needed) +🔼: uploading (unfinished) +🔽: downloading +✅: done +🌱: done and seeding" ;; + 6) "$TERMINAL" -e "$EDITOR" "$0" ;; +esac diff --git a/.local/bin/statusbar/volume b/.local/bin/statusbar/volume new file mode 100755 index 0000000..61588c3 --- /dev/null +++ b/.local/bin/statusbar/volume @@ -0,0 +1,28 @@ +#!/bin/sh + +# Prints the current volume or 🔇 if muted. + +case $BLOCK_BUTTON in + 1) setsid -f "$TERMINAL" -e pulsemixer ;; + 2) pamixer -t ;; + 4) pamixer --allow-boost -i 1 ;; + 5) pamixer --allow-boost -d 1 ;; + 3) notify-send "📢 Volume module" "\- Shows volume 🔊, 🔇 if muted. +- Middle click to mute. +- Scroll to change." ;; + 6) "$TERMINAL" -e "$EDITOR" "$0" ;; +esac + +[ $(pamixer --get-mute) = true ] && echo 🔇 && exit + +vol="$(pamixer --get-volume)" + +if [ "$vol" -gt "70" ]; then + icon="🔊" +elif [ "$vol" -lt "30" ]; then + icon="🔈" +else + icon="🔉" +fi + +echo "$icon$vol%" diff --git a/.local/bin/yapf b/.local/bin/yapf new file mode 100755 index 0000000..4b4d755 --- /dev/null +++ b/.local/bin/yapf @@ -0,0 +1,8 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +import re +import sys +from yapf import run_main +if __name__ == '__main__': + sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) + sys.exit(run_main()) diff --git a/.local/bin/zathura b/.local/bin/zathura new file mode 120000 index 0000000..3bf6e37 --- /dev/null +++ b/.local/bin/zathura @@ -0,0 +1 @@ +/home/dizzy/dox/opt/Zathura-Pywal/zathura \ No newline at end of file