Fix power settings for bluetooth and wifi in auxmenu

Signed-off-by: magic_rb <magic_rb@redalder.org>
This commit is contained in:
magic_rb 2023-11-18 13:45:11 +01:00
parent 01421acf78
commit 8ebc3a65ba
No known key found for this signature in database
GPG key ID: 08D5287CC5DDCA0E

View file

@ -10,19 +10,24 @@ then
wpctl set-mute @DEFAULT_AUDIO_SOURCE@ toggle wpctl set-mute @DEFAULT_AUDIO_SOURCE@ toggle
;; ;;
toggle-wifi) 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 then
nmcli radio wifi off iwctl adapter phy0 set-property Powered off
else else
nmcli radio wifi on iwctl adapter phy0 set-property Powered on
fi fi
;; ;;
toggle-bluetooth) toggle-bluetooth)
if [ "$(nmcli radio wifi)" = "enabled" ] if [ "$(bluetoothctl show | grep -i powered | tr '\t' ' ' | cut -f 3 -d ' ')" = "yes" ]
then then
nmcli radio wifi off bluetoothctl power off
else else
nmcli radio wifi on bluetoothctl power on
fi fi
;; ;;
screenshot-all) screenshot-all)