From 8ebc3a65ba4897d1b28f5feac9118bf2257fa94b Mon Sep 17 00:00:00 2001 From: magic_rb Date: Sat, 18 Nov 2023 13:45:11 +0100 Subject: [PATCH] Fix power settings for bluetooth and wifi in auxmenu Signed-off-by: magic_rb --- home-manager/modules/xmonad/scripts/auxmenu.sh | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/home-manager/modules/xmonad/scripts/auxmenu.sh b/home-manager/modules/xmonad/scripts/auxmenu.sh index edc9487..ba74e98 100644 --- a/home-manager/modules/xmonad/scripts/auxmenu.sh +++ b/home-manager/modules/xmonad/scripts/auxmenu.sh @@ -10,19 +10,24 @@ then wpctl set-mute @DEFAULT_AUDIO_SOURCE@ toggle ;; toggle-wifi) - if [ "$(nmcli radio wifi)" = "enabled" ] + function get_wifi_state() { + interface="$1" + + iwlist "$interface" power | sed 's/wlan0//' | awk '{$1=$1};1' | tr -s ' ' | grep "Current mode" | cut -d ':' -f 2 + } + if [ "$(get_wifi_state "wlan0")" = "on" ] then - nmcli radio wifi off + iwctl adapter phy0 set-property Powered off else - nmcli radio wifi on + iwctl adapter phy0 set-property Powered on fi ;; toggle-bluetooth) - if [ "$(nmcli radio wifi)" = "enabled" ] + if [ "$(bluetoothctl show | grep -i powered | tr '\t' ' ' | cut -f 3 -d ' ')" = "yes" ] then - nmcli radio wifi off + bluetoothctl power off else - nmcli radio wifi on + bluetoothctl power on fi ;; screenshot-all)