feat: optimized sbar, gammastep asia, wpdef

This commit is contained in:
ange 2025-04-30 02:41:45 +00:00
parent f48e958d44
commit 395119a0fe
Signed by: ange
GPG Key ID: 9E0C4157BB7BEB1D
19 changed files with 159 additions and 157 deletions

View File

@ -39,7 +39,7 @@ export DOCKER_HOST="unix://$XDG_RUNTIME_DIR/podman/podman.sock"
export SSH_AUTH_SOCK; SSH_AUTH_SOCK="$(gpgconf --list-dirs agent-ssh-socket)" export SSH_AUTH_SOCK; SSH_AUTH_SOCK="$(gpgconf --list-dirs agent-ssh-socket)"
# shellcheck disable=SC2046 # shellcheck disable=SC2046
systemctl --user import-environment PATH $(compgen -v XDG) systemctl --user import-environment PATH
[ -z "$DISPLAY" ] && [ "$XDG_VTNR" = 1 ] && { [ -z "$DISPLAY" ] && [ "$XDG_VTNR" = 1 ] && {
GUILOG="$HOME/.local/state/gui.log" GUILOG="$HOME/.local/state/gui.log"

View File

@ -44,7 +44,7 @@ function update() {
} }
function tmp() { function tmp() {
cd "$(mktemp -d "$1"XXX)" || return cd "$(mktemp -d /tmp/"$1"XXX)" || return
} }
alias -- \ alias -- \

View File

@ -59,6 +59,7 @@ alias kga='kubectl get "$(kubectl api-resources --verbs=list --namespaced -oname
compalias k=kubectl \ compalias k=kubectl \
ka='kubectl apply --recursive -f' \ ka='kubectl apply --recursive -f' \
kd='kubectl describe' \ kd='kubectl describe' \
kdno='kubectl describe node' \
kex='kubectl exec -i -t' \ kex='kubectl exec -i -t' \
kg='kubectl get' \ kg='kubectl get' \
kgno='kubectl get node' \ kgno='kubectl get node' \

View File

@ -25,6 +25,7 @@ function precmd() {
# shellcheck disable=SC2086 # shellcheck disable=SC2086
unset ${!PROMPT_P*} unset ${!PROMPT_P*}
PROMPT_PTIME="$(date -u '+%RZ')"
if [ -n "$VIRTUAL_ENV" ]; then if [ -n "$VIRTUAL_ENV" ]; then
PROMPT_PVENV="${VIRTUAL_ENV%/*}" && PROMPT_PVENV="${PROMPT_PVENV##*/}"$'\n' PROMPT_PVENV="${VIRTUAL_ENV%/*}" && PROMPT_PVENV="${PROMPT_PVENV##*/}"$'\n'
fi fi
@ -35,4 +36,4 @@ function precmd() {
PROMPT_PERR="${err// /|} " PROMPT_PERR="${err// /|} "
fi fi
} }
PS1='\[\e[00;38;5;37m\]$PROMPT_PVENV\[\e[38;5;134m\]$PROMPT_PK8S\[\e[00m\]$(__git_ps1 "%s ")\[\e[01;38;5;32m\]\w\[\e[00m\] \[\e[38;5;160m\]$PROMPT_PERR${_[\j<1]+\[\e[38;5;71m\]\j }\[\e[00m\]' PS1='\[\e[38;5;110m\]$PROMPT_PTIME \[\e[00;38;5;37m\]$PROMPT_PVENV\[\e[38;5;134m\]$PROMPT_PK8S\[\e[00m\]$(__git_ps1 "%s ")\[\e[01;38;5;32m\]\w\[\e[00m\] \[\e[38;5;160m\]$PROMPT_PERR${_[\j<1]+\[\e[38;5;71m\]\j }\[\e[00m\]'

View File

@ -1,10 +1,16 @@
# vim: tabstop=8 nowrap # vim: tabstop=8 nowrap
# TODO # TODO
https://xeiaso.net
https://anubis.techaro.lol/docs/admin/installation
https://nomads.com
https://wiki.nftables.org/wiki-nftables/index.php/Scripting
https://tech.yahoo.com/articles/mozilla-vpns-per-controls-too-182238290.html
https://help.gnome.org/users/zenity/stable/notification.html.en
https://serverfault.com/questions/1150627/bind9-behind-nginx-reverse-proxy-doh/1168780#1168780 https://serverfault.com/questions/1150627/bind9-behind-nginx-reverse-proxy-doh/1168780#1168780
https://www.grepular.com/Automatically_Encrypting_all_Incoming_Email https://www.grepular.com/Automatically_Encrypting_all_Incoming_Email
https://www.grepular.com/Protecting_a_Laptop_from_Simple_and_Sophisticated_Attacks https://www.grepular.com/Protecting_a_Laptop_from_Simple_and_Sophisticated_Attacks
https://www.rtcsec.com/article/slack-webrtc-turn-compromise-and-bug-bounty/ https://www.rtcsec.com/article/slack-webrtc-turn-compromise-and-bug-bounty
https://www.youtube.com/playlist?list=PLjAJj2LotlkOzOgp1xXJkbF73ZrQeDE7j https://www.youtube.com/playlist?list=PLjAJj2LotlkOzOgp1xXJkbF73ZrQeDE7j
comm/discord https://discord.com/app comm/discord https://discord.com/app
@ -71,6 +77,14 @@ media/watchsomuch https://watchsomuchtorrents.com
tools/archive https://archive.org tools/archive https://archive.org
tools/crypto/mtpelerin https://www.mtpelerin.com tools/crypto/mtpelerin https://www.mtpelerin.com
tools/gandi https://www.gandi.net tools/gandi https://www.gandi.net
tools/iso/arch https://archlinux.org/download
tools/iso/debian https://cdimage.debian.org/debian-cd/current/amd64/bt-cd
tools/iso/fedora https://torrent.fedoraproject.org
tools/iso/gmoker https://files.ovh.maby.dev/ISOs
tools/iso/gparted https://gparted.org/download.php
tools/iso/tails https://tails.net/install/download-iso/index.en.html
tools/iso/win11iotltsc https://www.microsoft.com/en-us/evalcenter/download-windows-11-enterprise
tools/iso/win2k25 https://www.microsoft.com/en-us/evalcenter/download-windows-server-2025
tools/memtest https://www.memtest.org tools/memtest https://www.memtest.org
tools/namecheap https://www.namecheap.com tools/namecheap https://www.namecheap.com
tools/nix/quickemu https://github.com/quickemu-project/quickemu tools/nix/quickemu https://github.com/quickemu-project/quickemu
@ -89,6 +103,5 @@ tools/win/malwarebytes https://www.malwarebytes.com
tools/win/massgrave https://massgrave.dev tools/win/massgrave https://massgrave.dev
tools/win/msmgtoolkit https://msmgtoolkit.in tools/win/msmgtoolkit https://msmgtoolkit.in
tools/win/office https://answers.microsoft.com/en-us/msoffice/forum/all/useful-microsoft-download-links-for-office-direct/7bcaa971-9493-44b6-a1ba-0db4c6957c47 tools/win/office https://answers.microsoft.com/en-us/msoffice/forum/all/useful-microsoft-download-links-for-office-direct/7bcaa971-9493-44b6-a1ba-0db4c6957c47
tools/win/server https://www.microsoft.com/en-us/evalcenter/download-windows-server-2025
tools/win/snappydriver http://www.snappy-driver-installer.org tools/win/snappydriver http://www.snappy-driver-installer.org
tools/z-library https://z-library.sk tools/z-library https://z-library.sk

View File

@ -4,5 +4,5 @@ temp-night=3500
location-provider=manual location-provider=manual
[manual] [manual]
lat=46 lat=-8.65
lon=2 lon=115

@ -1 +1 @@
Subproject commit 67a74c275d1116d575ab25485d1bfa6b2a9c38a6 Subproject commit 0e5512d1bebd1f08954710086f87a5caa173a924

@ -1 +1 @@
Subproject commit 523a9e148919f58eb5a013f76787e57696e00c93 Subproject commit 3b308861a8d7d7bfbe9be51d52e54dcfd9fe3d38

View File

@ -65,11 +65,13 @@ static const char *pwwwcmd[] = { "bookmarks", "-p", NULL };
static const char *calccmd[] = { "alacritty", "-epython", NULL }; static const char *calccmd[] = { "alacritty", "-epython", NULL };
static const char *fmcmd[] = { "pcmanfm", NULL }; static const char *fmcmd[] = { "pcmanfm", NULL };
static const char *prtsccmd[] = { "sh", "-c", "magick import png:- | xclip -sel c -t image/png && xclip -sel c -o | feh -", NULL }; static const char *prtsccmd[] = { "sh", "-c", "magick import png:- | xclip -sel c -t image/png && xclip -sel c -o | feh -", NULL };
static const char *lvolcmd[] = { "vol", "s", "-5", NULL }; static const char *spkdefcmd[] = { "wpdef", "s", NULL };
static const char *rvolcmd[] = { "vol", "s", "+5", NULL }; static const char *spklcmd[] = { "vol", "s", "-5", NULL };
static const char *mutecmd[] = { "vol", "s", "m", NULL }; static const char *spkrcmd[] = { "vol", "s", "+5", NULL };
static const char *miclvolcmd[] = { "vol", "m", "-5", NULL }; static const char *spkmutecmd[] = { "vol", "s", "m", NULL };
static const char *micrvolcmd[] = { "vol", "m", "+5", NULL }; static const char *micdefcmd[] = { "wpdef", "m", NULL };
static const char *miclcmd[] = { "vol", "m", "-5", NULL };
static const char *micrcmd[] = { "vol", "m", "+5", NULL };
static const char *micmutecmd[] = { "vol", "m", "m", NULL }; static const char *micmutecmd[] = { "vol", "m", "m", NULL };
static const char *pausecmd[] = { "playerctl", "play-pause", NULL }; static const char *pausecmd[] = { "playerctl", "play-pause", NULL };
static const char *prevcmd[] = { "playerctl", "previous", NULL }; static const char *prevcmd[] = { "playerctl", "previous", NULL };
@ -94,11 +96,13 @@ static const Key keys[] = {
{ 0, XF86XK_Calculator, spawn, {.v = calccmd } }, { 0, XF86XK_Calculator, spawn, {.v = calccmd } },
{ MODKEY, XK_e, spawn, {.v = fmcmd } }, { MODKEY, XK_e, spawn, {.v = fmcmd } },
{ 0, XK_Print, spawn, {.v = prtsccmd } }, { 0, XK_Print, spawn, {.v = prtsccmd } },
{ 0, XF86XK_AudioLowerVolume, spawn, {.v = lvolcmd } }, { MODKEY, XK_v, spawn, {.v = spkdefcmd } },
{ 0, XF86XK_AudioRaiseVolume, spawn, {.v = rvolcmd } }, { 0, XF86XK_AudioLowerVolume, spawn, {.v = spklcmd } },
{ 0, XF86XK_AudioMute, spawn, {.v = mutecmd } }, { 0, XF86XK_AudioRaiseVolume, spawn, {.v = spkrcmd } },
{ ShiftMask, XF86XK_AudioLowerVolume, spawn, {.v = miclvolcmd } }, { 0, XF86XK_AudioMute, spawn, {.v = spkmutecmd } },
{ ShiftMask, XF86XK_AudioRaiseVolume, spawn, {.v = micrvolcmd } }, { MODKEY|ShiftMask, XK_v, spawn, {.v = micdefcmd } },
{ ShiftMask, XF86XK_AudioLowerVolume, spawn, {.v = miclcmd } },
{ ShiftMask, XF86XK_AudioRaiseVolume, spawn, {.v = micrcmd } },
{ ShiftMask, XF86XK_AudioMute, spawn, {.v = micmutecmd } }, { ShiftMask, XF86XK_AudioMute, spawn, {.v = micmutecmd } },
{ 0, XF86XK_AudioMicMute, spawn, {.v = micmutecmd } }, { 0, XF86XK_AudioMicMute, spawn, {.v = micmutecmd } },
{ 0, XF86XK_AudioPlay, spawn, {.v = pausecmd } }, { 0, XF86XK_AudioPlay, spawn, {.v = pausecmd } },

View File

@ -1 +0,0 @@
../wallpaper.timer

View File

@ -1,6 +0,0 @@
[Unit]
Description=Randomly changes wallpaper
[Service]
Type=oneshot
ExecStart=bash wallpaper

View File

@ -1,9 +0,0 @@
[Unit]
Description=Randomly changes wallpaper
[Timer]
OnUnitInactiveSec=10min
Unit=wallpaper.service
[Install]
WantedBy=timers.target

@ -1 +1 @@
Subproject commit 0e935562f6c6931e809321374860c4bba74d297a Subproject commit d819f95e68ed7552b91fb7da4600ae65b6555667

View File

@ -4,46 +4,30 @@ import http.client as http
import json import json
# curl -sS https://api.coingecko.com/api/v3/coins/list # curl -sS https://api.coingecko.com/api/v3/coins/list
COINS = [ COINS = ["monero", "bitcoin"]
# [id, symbol]
["monero", "XMR"],
["bitcoin", "BTC"],
]
CURRENCY = "usd" CURRENCY = "usd"
FORMAT = "{coin}=${price:.0f}" FORMAT = "{symbol}=${price:.0f} {trend:+.1f}%"
def get_btc_fees() -> str: # https://docs.coingecko.com/v3.0.1/reference/coins-id
url = "mempool.space" def main():
path = "/api/v1/fees/mempool-blocks" path = "/api/v3/coins/{id}?localization=false&tickers=false&market_data=true&community_data=false&developer_data=false&sparkline=false"
client = http.HTTPSConnection("api.coingecko.com", timeout=10)
strings = []
client = http.HTTPSConnection(url, timeout=10) for c in COINS:
client.request("GET", path) client.request("GET", path.format(id=c))
j = json.loads(client.getresponse().read())
# https://mempool.space/docs/api/rest#get-mempool-blocks-fees strings.append(
response = json.loads(client.getresponse().read()) FORMAT.format(
return f"{int(response[0]['medianFee'])} sat/vB" symbol=j["symbol"].upper(),
price=j["market_data"]["current_price"][CURRENCY],
trend=j["market_data"]["price_change_percentage_24h"],
def get_coins_values() -> str: )
ids = ",".join([coin[0] for coin in COINS])
url = "api.coingecko.com"
path = f"/api/v3/simple/price?ids={ids}&vs_currencies={CURRENCY}"
client = http.HTTPSConnection(url, timeout=10)
client.request("GET", path)
# https://www.coingecko.com/api/documentation
prices = json.loads(client.getresponse().read())
return " ".join(
FORMAT.format(coin=coin[1], price=prices[coin[0]][CURRENCY])
for coin in COINS
) )
print(" - ".join(strings))
def main():
print(f"{get_btc_fees()} {get_coins_values()}")
if __name__ == "__main__": if __name__ == "__main__":

View File

@ -1,127 +1,117 @@
#!/bin/bash #!/bin/bash
function update_crypto() { function scrypto() {
local c local c
c="$(crypto 2> /dev/null)" && echo "$c" > "$SBAR/crypto" c="$(crypto 2> /dev/null)" && echo "$c" > crypto
} }
function update_cpu() { function scpu() {
echo " $(awk '{print $1}' /proc/loadavg)" > "$SBAR/cpu" echo " $(awk '{print $1}' /proc/loadavg)" > cpu
} }
function update_memory() { function smemory() {
echo " $(free -h | awk '/^Mem:/{print $3}')" > "$SBAR/memory" echo " $(free -h | awk '/^Mem:/{print $3}')" > memory
} }
function update_bat() { function sbat() {
local cap; cap="$(cat /sys/class/power_supply/BAT0/capacity)" local cap; cap="$(cat /sys/class/power_supply/BAT0/capacity)"
if grep -qv Discharging /sys/class/power_supply/BAT0/status; then if grep -qv Discharging /sys/class/power_supply/BAT0/status; then
echo " $cap%" > "$SBAR/bat" echo " $cap%"
else else
echo " $cap%" > "$SBAR/bat" echo " $cap%"
fi fi > bat
} }
function update_sink_vol() { function svol() {
local vol mute local st v vol=('' ' ') mut=('🔇' ' ') m
read -r _ vol mute < <(wpctl get-volume '@DEFAULT_AUDIO_SINK@') || return mapfile -t st <<< "$(wpctl status | sed -n 's/.*\*.*\[vol: \(.*\)]/\1/p')"
if [ -n "$mute" ]; then if [ -z "${st[0]}" ]; then
echo '🔇' > "$SBAR/sink" return > vol
else
echo " $((10#${vol/./}))" > "$SBAR/sink"
fi fi
for i in "${!vol[@]}"; do
read -r v m <<< "${st[$i]}"
if [ -n "$m" ]; then
echo -n "${mut[$i]}"
else
echo -n "${vol[$i]} $((10#${v/./}))"
fi
done > vol
} }
function update_source_vol() { function snet() {
local vol mute
read -r _ vol mute < <(wpctl get-volume '@DEFAULT_AUDIO_SOURCE@') || return
if [ -n "$mute" ]; then
echo '' > "$SBAR/source"
else
echo " $((10#${vol/./}))" > "$SBAR/source"
fi
}
function update_net() {
local dev j ssid sig local dev j ssid sig
dev="$(ip route | grep -oP 'default.*dev\s+\K[^\s]+')" dev="$(ip route | grep -oP 'default.*dev\s+\K[^\s]+')"
j="$(networkctl status "$dev" --json=short)" j="$(networkctl status "$dev" --json=short)"
case "$(jq -r .Type <<< "$j")" in case "$(jq -r .Type <<< "$j")" in
ether) ether)
echo "🌐 $dev" > "$SBAR/net" echo "🌐 $dev"
;; ;;
wlan) wlan)
ssid="$(jq -r .SSID <<< "$j")" ssid="$(jq -r .SSID <<< "$j")"
sig="$(awk "/$dev/{printf \"%.0f\", \$3}" /proc/net/wireless)" sig="$(awk "/$dev/{printf \"%.0f\", \$3}" /proc/net/wireless)"
if [ "$sig" -gt 56 ]; then echo "▂▄▆█ $ssid" > "$SBAR/net" if [ "$sig" -gt 56 ]; then echo "▂▄▆█ $ssid"
elif [ "$sig" -gt 38 ]; then echo "▂▄▆_ $ssid" > "$SBAR/net" elif [ "$sig" -gt 38 ]; then echo "▂▄▆_ $ssid"
elif [ "$sig" -gt 21 ]; then echo "▂▄__ $ssid" > "$SBAR/net" elif [ "$sig" -gt 21 ]; then echo "▂▄__ $ssid"
elif [ "$sig" -gt 3 ]; then echo "▂___ $ssid" > "$SBAR/net" elif [ "$sig" -gt 3 ]; then echo "▂___ $ssid"
else echo "____ $ssid" > "$SBAR/net" else echo "____ $ssid"
fi fi
;; ;;
*) *)
echo '⚠' > "$SBAR/net" echo '⚠'
;; ;;
esac esac > net
} }
function update_vpn() { function svpn() {
local v; v="$(ip -br link show type wireguard | awk '{print $1}')" local v; v="$(ip -br link show type wireguard | awk '{print $1}')"
if [ -n "$v" ]; then if [ -n "$v" ]; then
echo " 🔒 $v" > "$SBAR/vpn" echo " 🔒 $v"
else fi > vpn
: > "$SBAR/vpn"
fi
} }
function update_time() { function stime() {
echo "$(TZ=Asia/Makassar date '+%R %Z') - $(date -u '+%a %m-%d %R')" \ # shellcheck disable=SC2238
> "$SBAR/time" TZ=Asia/Makassar date '+%a %m-%d %R %Z' > time
} }
function display() { function display() {
for f in "$SBAR"/*; do for f in *; do
local "$(basename "$f")"="$(cat "$f")" local - "$f"="$(cat "$f")"
done done
# shellcheck disable=SC2154 # shellcheck disable=SC2128,SC2154
xsetroot -name "$crypto | $cpu | $memory | $sink $source | $net$vpn | $bat | $time" xsetroot -name "$crypto | $cpu | $memory | $vol | $net$vpn | $bat | $time"
} }
# SIGNALING # SIGNALING
# trap '<function>;display;wait -n' 'RTMIN+n' # trap '<function>;display;wait' 'RTMIN+n'
trap 'update_sink_vol;display;wait -n' 'RTMIN+0' trap 'svol;display;wait' 'RTMIN+0'
trap 'update_source_vol;display;wait -n' 'RTMIN+1' trap 'snet;display;wait' 'RTMIN+1'
trap 'update_net;display;wait -n' 'RTMIN+2' trap 'svpn;display;wait' 'RTMIN+2'
trap 'update_vpn;display;wait -n' 'RTMIN+3'
# to update it from external commands # to update it from external commands
## kill -m "$(cat "$XDG_CACHE_HOME/pidofbar")" ## kill -m "$(cat "$XDG_CACHE_HOME/pidofbar")"
# where m = 34 + n # where m = 34 + n
SBAR="$XDG_CACHE_HOME/sbar" mkdir -p "$XDG_RUNTIME_DIR/sbar" && cd "$XDG_RUNTIME_DIR/sbar" || exit 1
mkdir -p "$SBAR" echo "$$" > pid
echo "$$" > "$SBAR/pid"
(while :; do (while :; do
update_crypto scrypto
sleep $((300 - 10#$(date '+%S') % 300)) & wait -n sleep $((300 - 10#$(date '+%S') % 300)) & wait
done &) done &)
while true; do while true; do
update_cpu scpu
update_memory smemory
update_sink_vol svol
update_source_vol snet
update_net svpn
update_vpn sbat
update_bat stime
update_time
display display
sleep $((5 - 10#$(date '+%S') % 5)) & wait -n sleep $((5 - 10#$(date '+%S') % 5)) & wait
done done

View File

@ -3,50 +3,43 @@
case "$1" in case "$1" in
s) s)
DEV='@DEFAULT_AUDIO_SINK@' DEV='@DEFAULT_AUDIO_SINK@'
SIG=34
;; ;;
m) m)
DEV='@DEFAULT_AUDIO_SOURCE@' DEV='@DEFAULT_AUDIO_SOURCE@'
SIG=35
;; ;;
*) *)
exit 1 exit 1
;; ;;
esac esac
shift
function update_vol() { function update_vol() {
case "$1" in case "$1" in
+*|-*) +*|-*)
# shellcheck disable=SC2017 # shellcheck disable=SC2017
CUR=$((CUR + $1 - CUR % $1 + CUR % $1 * 10 / $1 / 5 * $1)) CUR=$((CUR + $1 - CUR % $1 + CUR % $1 * 10 / $1 / 5 * $1))
if [ "$CUR" -lt 0 ]; then
CUR=0
elif [ "$CUR" -gt 300 ]; then
CUR=300
fi
;; ;;
*) *)
CUR="$1" CUR="$1"
esac esac
wpctl set-volume "$DEV" "$CUR%" wpctl set-volume -l 3 "$DEV" "$CUR%"
} }
read -r _ CUR MUTE < <(wpctl get-volume "$DEV") read -r _ CUR MUTE < <(wpctl get-volume "$DEV")
CUR=$((10#${CUR/./})) CUR=$((10#${CUR/./}))
if [ -z "$1" ]; then if [ -z "$2" ]; then
echo "$CUR" echo "$CUR"
exit exit
elif [ "$1" == 'm' ] && [ -z "$MUTE" ]; then fi
if [ "$2" == 'm' ] && [ -z "$MUTE" ]; then
wpctl set-mute "$DEV" 1 wpctl set-mute "$DEV" 1
else else
if [[ "$1" =~ [0-9] ]]; then if [[ "$2" =~ [0-9] ]]; then
update_vol "$1" update_vol "$2"
fi fi
if [ -n "$MUTE" ]; then if [ -n "$MUTE" ]; then
wpctl set-mute "$DEV" 0 wpctl set-mute "$DEV" 0
fi fi
fi fi
kill "-$SIG" "$(cat "$XDG_CACHE_HOME/sbar/pid")" kill -34 "$(cat "$XDG_RUNTIME_DIR/sbar/pid")"

View File

@ -9,7 +9,7 @@ fi
if [ "$EUID" != 0 ]; then if [ "$EUID" != 0 ]; then
exec "$SUDO" env DISPLAY="$DISPLAY" XAUTHORITY="$XAUTHORITY" \ exec "$SUDO" env DISPLAY="$DISPLAY" XAUTHORITY="$XAUTHORITY" \
XDG_CACHE_HOME="$XDG_CACHE_HOME" "$BASH" -- "${BASH_SOURCE[0]}" "$@" XDG_RUNTIME_DIR="$XDG_RUNTIME_DIR" "$BASH" -- "${BASH_SOURCE[0]}" "$@"
fi fi
if [ "$1" != off ]; then if [ "$1" != off ]; then
@ -23,4 +23,4 @@ while read -r i; do
wg-quick down "$i" wg-quick down "$i"
done < <(ip -br link show type wireguard | awk "\$1 != \"$1\"{print \$1}") done < <(ip -br link show type wireguard | awk "\$1 != \"$1\"{print \$1}")
kill -37 "$(cat "$XDG_CACHE_HOME/sbar/pid")" kill -36 "$(cat "$XDG_RUNTIME_DIR/sbar/pid")"

View File

@ -9,7 +9,7 @@ fi
for _ in {0..29}; do for _ in {0..29}; do
if "${iwctl[@]}" show | grep -q '\s*State\s\+connected\s*$'; then if "${iwctl[@]}" show | grep -q '\s*State\s\+connected\s*$'; then
kill -36 "$(cat "$XDG_CACHE_HOME/sbar/pid")" kill -35 "$(cat "$XDG_RUNTIME_DIR/sbar/pid")"
exit 0 exit 0
fi fi
sleep 1 sleep 1

32
.local/bin/wpdef Executable file
View File

@ -0,0 +1,32 @@
#!/bin/bash -e
json="$(pw-dump)"
function getdevs() {
jq -r ".[] | select(.info.props.\"media.class\" == \"Audio/$1\") | \"\(.id) \(.info.props.\"node.nick\")\"" <<< "$json"
}
function getdefault() {
jq -r ".[].metadata | select(.) | .[] | select(.key == \"default.configured.audio.$1\") | .value.name" <<< "$json"
}
function getnick() {
jq -r ".[].info.props | select(.\"node.name\" == \"$1\") | .\"node.nick\"" <<< "$json"
}
case "$1" in
s)
CLASS=Sink
;;
m)
CLASS=Source
;;
*)
exit 1
;;
esac
read -r id <<< "$(getdevs "$CLASS" | dmenu -l 16)"
wpctl set-default "$id"
kill -34 "$(cat "$XDG_RUNTIME_DIR/sbar/pid")"