From 395119a0febceb34a35efc5fbfdf31c217777419 Mon Sep 17 00:00:00 2001 From: ange Date: Wed, 30 Apr 2025 02:41:45 +0000 Subject: [PATCH] feat: optimized sbar, gammastep asia, wpdef --- .bash_profile | 2 +- .config/bash/10-aliases.bash | 2 +- .config/bash/11-k8s.bash | 1 + .config/bash/20-theme.bash | 3 +- .config/bookmarks | 17 ++- .config/gammastep/config.ini | 4 +- .config/nvim/pack/plugins/start/onedark | 2 +- .config/nvim/pack/plugins/start/treesitter | 2 +- .config/suckless/dwm-6.5/config.h | 24 ++-- .../user/timers.target.wants/wallpaper.timer | 1 - .config/systemd/user/wallpaper.service | 6 - .config/systemd/user/wallpaper.timer | 9 -- .local/aur/newsraft | 2 +- .local/bin/crypto | 56 +++----- .local/bin/sbar | 126 ++++++++---------- .local/bin/vol | 21 +-- .local/bin/vpn | 4 +- .local/bin/wlp | 2 +- .local/bin/wpdef | 32 +++++ 19 files changed, 159 insertions(+), 157 deletions(-) delete mode 120000 .config/systemd/user/timers.target.wants/wallpaper.timer delete mode 100644 .config/systemd/user/wallpaper.service delete mode 100644 .config/systemd/user/wallpaper.timer create mode 100755 .local/bin/wpdef diff --git a/.bash_profile b/.bash_profile index f27e7a5..6ed7d0c 100644 --- a/.bash_profile +++ b/.bash_profile @@ -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)" # shellcheck disable=SC2046 -systemctl --user import-environment PATH $(compgen -v XDG) +systemctl --user import-environment PATH [ -z "$DISPLAY" ] && [ "$XDG_VTNR" = 1 ] && { GUILOG="$HOME/.local/state/gui.log" diff --git a/.config/bash/10-aliases.bash b/.config/bash/10-aliases.bash index ae77ce4..71ddead 100644 --- a/.config/bash/10-aliases.bash +++ b/.config/bash/10-aliases.bash @@ -44,7 +44,7 @@ function update() { } function tmp() { - cd "$(mktemp -d "$1"XXX)" || return + cd "$(mktemp -d /tmp/"$1"XXX)" || return } alias -- \ diff --git a/.config/bash/11-k8s.bash b/.config/bash/11-k8s.bash index f9a20c2..327f1a3 100644 --- a/.config/bash/11-k8s.bash +++ b/.config/bash/11-k8s.bash @@ -59,6 +59,7 @@ alias kga='kubectl get "$(kubectl api-resources --verbs=list --namespaced -oname compalias k=kubectl \ ka='kubectl apply --recursive -f' \ kd='kubectl describe' \ + kdno='kubectl describe node' \ kex='kubectl exec -i -t' \ kg='kubectl get' \ kgno='kubectl get node' \ diff --git a/.config/bash/20-theme.bash b/.config/bash/20-theme.bash index 41d090b..7c83a39 100644 --- a/.config/bash/20-theme.bash +++ b/.config/bash/20-theme.bash @@ -25,6 +25,7 @@ function precmd() { # shellcheck disable=SC2086 unset ${!PROMPT_P*} + PROMPT_PTIME="$(date -u '+%RZ')" if [ -n "$VIRTUAL_ENV" ]; then PROMPT_PVENV="${VIRTUAL_ENV%/*}" && PROMPT_PVENV="${PROMPT_PVENV##*/}"$'\n' fi @@ -35,4 +36,4 @@ function precmd() { PROMPT_PERR="${err// /|} " 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\]' diff --git a/.config/bookmarks b/.config/bookmarks index 8a856df..8d2ba0d 100644 --- a/.config/bookmarks +++ b/.config/bookmarks @@ -1,10 +1,16 @@ # vim: tabstop=8 nowrap # 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://www.grepular.com/Automatically_Encrypting_all_Incoming_Email 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 comm/discord https://discord.com/app @@ -71,6 +77,14 @@ media/watchsomuch https://watchsomuchtorrents.com tools/archive https://archive.org tools/crypto/mtpelerin https://www.mtpelerin.com 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/namecheap https://www.namecheap.com 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/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/server https://www.microsoft.com/en-us/evalcenter/download-windows-server-2025 tools/win/snappydriver http://www.snappy-driver-installer.org tools/z-library https://z-library.sk diff --git a/.config/gammastep/config.ini b/.config/gammastep/config.ini index 571eab6..1e1f71f 100644 --- a/.config/gammastep/config.ini +++ b/.config/gammastep/config.ini @@ -4,5 +4,5 @@ temp-night=3500 location-provider=manual [manual] -lat=46 -lon=2 +lat=-8.65 +lon=115 diff --git a/.config/nvim/pack/plugins/start/onedark b/.config/nvim/pack/plugins/start/onedark index 67a74c2..0e5512d 160000 --- a/.config/nvim/pack/plugins/start/onedark +++ b/.config/nvim/pack/plugins/start/onedark @@ -1 +1 @@ -Subproject commit 67a74c275d1116d575ab25485d1bfa6b2a9c38a6 +Subproject commit 0e5512d1bebd1f08954710086f87a5caa173a924 diff --git a/.config/nvim/pack/plugins/start/treesitter b/.config/nvim/pack/plugins/start/treesitter index 523a9e1..3b30886 160000 --- a/.config/nvim/pack/plugins/start/treesitter +++ b/.config/nvim/pack/plugins/start/treesitter @@ -1 +1 @@ -Subproject commit 523a9e148919f58eb5a013f76787e57696e00c93 +Subproject commit 3b308861a8d7d7bfbe9be51d52e54dcfd9fe3d38 diff --git a/.config/suckless/dwm-6.5/config.h b/.config/suckless/dwm-6.5/config.h index ef1eff0..3758a50 100644 --- a/.config/suckless/dwm-6.5/config.h +++ b/.config/suckless/dwm-6.5/config.h @@ -65,11 +65,13 @@ static const char *pwwwcmd[] = { "bookmarks", "-p", NULL }; static const char *calccmd[] = { "alacritty", "-epython", 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 *lvolcmd[] = { "vol", "s", "-5", NULL }; -static const char *rvolcmd[] = { "vol", "s", "+5", NULL }; -static const char *mutecmd[] = { "vol", "s", "m", NULL }; -static const char *miclvolcmd[] = { "vol", "m", "-5", NULL }; -static const char *micrvolcmd[] = { "vol", "m", "+5", NULL }; +static const char *spkdefcmd[] = { "wpdef", "s", NULL }; +static const char *spklcmd[] = { "vol", "s", "-5", NULL }; +static const char *spkrcmd[] = { "vol", "s", "+5", NULL }; +static const char *spkmutecmd[] = { "vol", "s", "m", 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 *pausecmd[] = { "playerctl", "play-pause", NULL }; static const char *prevcmd[] = { "playerctl", "previous", NULL }; @@ -94,11 +96,13 @@ static const Key keys[] = { { 0, XF86XK_Calculator, spawn, {.v = calccmd } }, { MODKEY, XK_e, spawn, {.v = fmcmd } }, { 0, XK_Print, spawn, {.v = prtsccmd } }, - { 0, XF86XK_AudioLowerVolume, spawn, {.v = lvolcmd } }, - { 0, XF86XK_AudioRaiseVolume, spawn, {.v = rvolcmd } }, - { 0, XF86XK_AudioMute, spawn, {.v = mutecmd } }, - { ShiftMask, XF86XK_AudioLowerVolume, spawn, {.v = miclvolcmd } }, - { ShiftMask, XF86XK_AudioRaiseVolume, spawn, {.v = micrvolcmd } }, + { MODKEY, XK_v, spawn, {.v = spkdefcmd } }, + { 0, XF86XK_AudioLowerVolume, spawn, {.v = spklcmd } }, + { 0, XF86XK_AudioRaiseVolume, spawn, {.v = spkrcmd } }, + { 0, XF86XK_AudioMute, spawn, {.v = spkmutecmd } }, + { 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 } }, { 0, XF86XK_AudioMicMute, spawn, {.v = micmutecmd } }, { 0, XF86XK_AudioPlay, spawn, {.v = pausecmd } }, diff --git a/.config/systemd/user/timers.target.wants/wallpaper.timer b/.config/systemd/user/timers.target.wants/wallpaper.timer deleted file mode 120000 index c1a751b..0000000 --- a/.config/systemd/user/timers.target.wants/wallpaper.timer +++ /dev/null @@ -1 +0,0 @@ -../wallpaper.timer \ No newline at end of file diff --git a/.config/systemd/user/wallpaper.service b/.config/systemd/user/wallpaper.service deleted file mode 100644 index 13b2220..0000000 --- a/.config/systemd/user/wallpaper.service +++ /dev/null @@ -1,6 +0,0 @@ -[Unit] -Description=Randomly changes wallpaper - -[Service] -Type=oneshot -ExecStart=bash wallpaper diff --git a/.config/systemd/user/wallpaper.timer b/.config/systemd/user/wallpaper.timer deleted file mode 100644 index e3766cb..0000000 --- a/.config/systemd/user/wallpaper.timer +++ /dev/null @@ -1,9 +0,0 @@ -[Unit] -Description=Randomly changes wallpaper - -[Timer] -OnUnitInactiveSec=10min -Unit=wallpaper.service - -[Install] -WantedBy=timers.target diff --git a/.local/aur/newsraft b/.local/aur/newsraft index 0e93556..d819f95 160000 --- a/.local/aur/newsraft +++ b/.local/aur/newsraft @@ -1 +1 @@ -Subproject commit 0e935562f6c6931e809321374860c4bba74d297a +Subproject commit d819f95e68ed7552b91fb7da4600ae65b6555667 diff --git a/.local/bin/crypto b/.local/bin/crypto index 6e8d0dc..a49ba5c 100755 --- a/.local/bin/crypto +++ b/.local/bin/crypto @@ -4,46 +4,30 @@ import http.client as http import json # curl -sS https://api.coingecko.com/api/v3/coins/list -COINS = [ - # [id, symbol] - ["monero", "XMR"], - ["bitcoin", "BTC"], -] +COINS = ["monero", "bitcoin"] CURRENCY = "usd" -FORMAT = "{coin}=${price:.0f}" - - -def get_btc_fees() -> str: - url = "mempool.space" - path = "/api/v1/fees/mempool-blocks" - - client = http.HTTPSConnection(url, timeout=10) - client.request("GET", path) - - # https://mempool.space/docs/api/rest#get-mempool-blocks-fees - response = json.loads(client.getresponse().read()) - return f"{int(response[0]['medianFee'])} sat/vB" - - -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 - ) +FORMAT = "{symbol}=${price:.0f} {trend:+.1f}%" +# https://docs.coingecko.com/v3.0.1/reference/coins-id def main(): - print(f"{get_btc_fees()} {get_coins_values()}") + 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 = [] + + for c in COINS: + client.request("GET", path.format(id=c)) + j = json.loads(client.getresponse().read()) + + strings.append( + FORMAT.format( + symbol=j["symbol"].upper(), + price=j["market_data"]["current_price"][CURRENCY], + trend=j["market_data"]["price_change_percentage_24h"], + ) + ) + + print(" - ".join(strings)) if __name__ == "__main__": diff --git a/.local/bin/sbar b/.local/bin/sbar index 7d211e6..303ed13 100755 --- a/.local/bin/sbar +++ b/.local/bin/sbar @@ -1,127 +1,117 @@ #!/bin/bash -function update_crypto() { +function scrypto() { local c - c="$(crypto 2> /dev/null)" && echo "$c" > "$SBAR/crypto" + c="$(crypto 2> /dev/null)" && echo "$c" > crypto } -function update_cpu() { - echo " $(awk '{print $1}' /proc/loadavg)" > "$SBAR/cpu" +function scpu() { + echo " $(awk '{print $1}' /proc/loadavg)" > cpu } -function update_memory() { - echo " $(free -h | awk '/^Mem:/{print $3}')" > "$SBAR/memory" +function smemory() { + echo " $(free -h | awk '/^Mem:/{print $3}')" > memory } -function update_bat() { +function sbat() { local cap; cap="$(cat /sys/class/power_supply/BAT0/capacity)" if grep -qv Discharging /sys/class/power_supply/BAT0/status; then - echo " $cap%" > "$SBAR/bat" + echo " $cap%" else - echo " $cap%" > "$SBAR/bat" - fi + echo " $cap%" + fi > bat } -function update_sink_vol() { - local vol mute +function svol() { + local st v vol=('' ' ') mut=('🔇' ' ') m - read -r _ vol mute < <(wpctl get-volume '@DEFAULT_AUDIO_SINK@') || return - if [ -n "$mute" ]; then - echo '🔇' > "$SBAR/sink" - else - echo " $((10#${vol/./}))" > "$SBAR/sink" + mapfile -t st <<< "$(wpctl status | sed -n 's/.*\*.*\[vol: \(.*\)]/\1/p')" + if [ -z "${st[0]}" ]; then + return > vol 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() { - 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() { +function snet() { local dev j ssid sig dev="$(ip route | grep -oP 'default.*dev\s+\K[^\s]+')" j="$(networkctl status "$dev" --json=short)" case "$(jq -r .Type <<< "$j")" in ether) - echo "🌐 $dev" > "$SBAR/net" + echo "🌐 $dev" ;; wlan) ssid="$(jq -r .SSID <<< "$j")" sig="$(awk "/$dev/{printf \"%.0f\", \$3}" /proc/net/wireless)" - if [ "$sig" -gt 56 ]; then echo "▂▄▆█ $ssid" > "$SBAR/net" - elif [ "$sig" -gt 38 ]; then echo "▂▄▆_ $ssid" > "$SBAR/net" - elif [ "$sig" -gt 21 ]; then echo "▂▄__ $ssid" > "$SBAR/net" - elif [ "$sig" -gt 3 ]; then echo "▂___ $ssid" > "$SBAR/net" - else echo "____ $ssid" > "$SBAR/net" + if [ "$sig" -gt 56 ]; then echo "▂▄▆█ $ssid" + elif [ "$sig" -gt 38 ]; then echo "▂▄▆_ $ssid" + elif [ "$sig" -gt 21 ]; then echo "▂▄__ $ssid" + elif [ "$sig" -gt 3 ]; then echo "▂___ $ssid" + else echo "____ $ssid" 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}')" if [ -n "$v" ]; then - echo " 🔒 $v" > "$SBAR/vpn" - else - : > "$SBAR/vpn" - fi + echo " 🔒 $v" + fi > vpn } -function update_time() { - echo "$(TZ=Asia/Makassar date '+%R %Z') - $(date -u '+%a %m-%d %R')" \ - > "$SBAR/time" +function stime() { + # shellcheck disable=SC2238 + TZ=Asia/Makassar date '+%a %m-%d %R %Z' > time } function display() { - for f in "$SBAR"/*; do - local "$(basename "$f")"="$(cat "$f")" + for f in *; do + local - "$f"="$(cat "$f")" done - # shellcheck disable=SC2154 - xsetroot -name "$crypto | $cpu | $memory | $sink $source | $net$vpn | $bat | $time" + # shellcheck disable=SC2128,SC2154 + xsetroot -name "$crypto | $cpu | $memory | $vol | $net$vpn | $bat | $time" } # SIGNALING -# trap ';display;wait -n' 'RTMIN+n' -trap 'update_sink_vol;display;wait -n' 'RTMIN+0' -trap 'update_source_vol;display;wait -n' 'RTMIN+1' -trap 'update_net;display;wait -n' 'RTMIN+2' -trap 'update_vpn;display;wait -n' 'RTMIN+3' +# trap ';display;wait' 'RTMIN+n' +trap 'svol;display;wait' 'RTMIN+0' +trap 'snet;display;wait' 'RTMIN+1' +trap 'svpn;display;wait' 'RTMIN+2' # to update it from external commands ## kill -m "$(cat "$XDG_CACHE_HOME/pidofbar")" # where m = 34 + n -SBAR="$XDG_CACHE_HOME/sbar" -mkdir -p "$SBAR" -echo "$$" > "$SBAR/pid" +mkdir -p "$XDG_RUNTIME_DIR/sbar" && cd "$XDG_RUNTIME_DIR/sbar" || exit 1 +echo "$$" > pid (while :; do - update_crypto - sleep $((300 - 10#$(date '+%S') % 300)) & wait -n + scrypto + sleep $((300 - 10#$(date '+%S') % 300)) & wait done &) while true; do - update_cpu - update_memory - update_sink_vol - update_source_vol - update_net - update_vpn - update_bat - update_time + scpu + smemory + svol + snet + svpn + sbat + stime display - sleep $((5 - 10#$(date '+%S') % 5)) & wait -n + sleep $((5 - 10#$(date '+%S') % 5)) & wait done diff --git a/.local/bin/vol b/.local/bin/vol index 3402898..714e38a 100755 --- a/.local/bin/vol +++ b/.local/bin/vol @@ -3,50 +3,43 @@ case "$1" in s) DEV='@DEFAULT_AUDIO_SINK@' - SIG=34 ;; m) DEV='@DEFAULT_AUDIO_SOURCE@' - SIG=35 ;; *) exit 1 ;; esac -shift function update_vol() { case "$1" in +*|-*) # shellcheck disable=SC2017 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" esac - wpctl set-volume "$DEV" "$CUR%" + wpctl set-volume -l 3 "$DEV" "$CUR%" } read -r _ CUR MUTE < <(wpctl get-volume "$DEV") CUR=$((10#${CUR/./})) -if [ -z "$1" ]; then +if [ -z "$2" ]; then echo "$CUR" exit -elif [ "$1" == 'm' ] && [ -z "$MUTE" ]; then +fi +if [ "$2" == 'm' ] && [ -z "$MUTE" ]; then wpctl set-mute "$DEV" 1 else - if [[ "$1" =~ [0-9] ]]; then - update_vol "$1" + if [[ "$2" =~ [0-9] ]]; then + update_vol "$2" fi if [ -n "$MUTE" ]; then wpctl set-mute "$DEV" 0 fi fi -kill "-$SIG" "$(cat "$XDG_CACHE_HOME/sbar/pid")" +kill -34 "$(cat "$XDG_RUNTIME_DIR/sbar/pid")" diff --git a/.local/bin/vpn b/.local/bin/vpn index 7e737a3..ef42ef7 100755 --- a/.local/bin/vpn +++ b/.local/bin/vpn @@ -9,7 +9,7 @@ fi if [ "$EUID" != 0 ]; then 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 if [ "$1" != off ]; then @@ -23,4 +23,4 @@ while read -r i; do wg-quick down "$i" 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")" diff --git a/.local/bin/wlp b/.local/bin/wlp index dfccb08..ef1edad 100755 --- a/.local/bin/wlp +++ b/.local/bin/wlp @@ -9,7 +9,7 @@ fi for _ in {0..29}; do 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 fi sleep 1 diff --git a/.local/bin/wpdef b/.local/bin/wpdef new file mode 100755 index 0000000..86ba7bd --- /dev/null +++ b/.local/bin/wpdef @@ -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")"