From c97ddec619dcb2fcec993ecd748a5755775ff158 Mon Sep 17 00:00:00 2001 From: matt1432 Date: Tue, 26 Sep 2023 11:46:03 -0400 Subject: [PATCH] fix(ags quick-settings): switch to async execs and fix bluetooth toggle --- config/ags/bin/qs-toggles.sh | 2 +- config/ags/js/quick-settings/button-grid.js | 35 ++++++++++----------- 2 files changed, 18 insertions(+), 19 deletions(-) diff --git a/config/ags/bin/qs-toggles.sh b/config/ags/bin/qs-toggles.sh index 564dcf1e..b7be84ca 100755 --- a/config/ags/bin/qs-toggles.sh +++ b/config/ags/bin/qs-toggles.sh @@ -18,7 +18,7 @@ if [[ $1 == "toggle-radio" ]]; then fi fi - +FILE='/home/matt/.config/.bluetooth' get_state() { if [[ "$(rfkill list | grep -A 1 hci0 | grep -o no)" == "no" ]]; then echo " 󰂯 " > "$FILE" diff --git a/config/ags/js/quick-settings/button-grid.js b/config/ags/js/quick-settings/button-grid.js index 4f6c58cb..f8b97e61 100644 --- a/config/ags/js/quick-settings/button-grid.js +++ b/config/ags/js/quick-settings/button-grid.js @@ -1,6 +1,7 @@ const { Box, CenterBox, Label, Icon } = ags.Widget; const { Network, Bluetooth, Audio } = ags.Service; -const { exec } = ags.Utils; +const { execAsync } = ags.Utils; +const { openWindow } = ags.App; import { EventBox } from '../misc/cursorbox.js'; @@ -34,7 +35,7 @@ const FirstRow = Box({ GridButton({ command: () => Network.toggleWifi(), - secondaryCommand: () => exec("bash -c 'nm-connection-editor &'"), + secondaryCommand: () => execAsync(['bash', '-c', 'nm-connection-editor']).catch(print), icon: Icon({ className: 'grid-label', connections: [[Network, icon => { @@ -49,26 +50,26 @@ const FirstRow = Box({ }), GridButton({ - command: () => exec("bash -c '$AGS_PATH/qs-toggles.sh blue-toggle'"), - secondaryCommand: () => exec("bash -c 'blueberry &'"), + command: () => execAsync(['bash', '-c', '$AGS_PATH/qs-toggles.sh blue-toggle']).catch(print), + secondaryCommand: () => execAsync(['bash', '-c', 'blueberry']).catch(print), icon: Icon({ className: 'grid-label', connections: [[Bluetooth, icon => { if (Bluetooth.enabled) { icon.icon = 'bluetooth-active-symbolic'; - exec('bash -c "echo 󰂯 > $HOME/.config/.bluetooth"'); + execAsync(['bash', '-c', 'echo 󰂯 > $HOME/.config/.bluetooth']).catch(print); } else { icon.icon = 'bluetooth-disabled-symbolic'; - exec('bash -c "echo 󰂲 > $HOME/.config/.bluetooth"'); + execAsync(['bash', '-c', 'echo 󰂲 > $HOME/.config/.bluetooth']).catch(print); } }, 'changed']], }) }), GridButton({ - command: () => exec('bash -c "$AGS_PATH/qs-toggles.sh toggle-radio"'), - secondaryCommand: () => exec("notify-send 'set this up moron'"), + command: () => execAsync(['bash', '-c', '$AGS_PATH/qs-toggles.sh toggle-radio']).catch(print), + secondaryCommand: () => execAsync(['notify-send', 'set this up moron']).catch(print), icon: Icon({ className: 'grid-label', connections: [[Network, icon => { @@ -103,7 +104,8 @@ const SubRow = CenterBox({ truncate: 'end', maxWidthChars: 12, connections: [[Bluetooth, label => { - label.label = String(Bluetooth.connectedDevices[0]); + label.label = Bluetooth.connectedDevices[0] ? String(Bluetooth.connectedDevices[0]) : + 'Disconnected'; }, 'changed']], }), @@ -140,8 +142,8 @@ const SecondRow = Box({ children: [ GridButton({ - command: () => exec("swayosd-client --output-volume mute-toggle"), - secondaryCommand: () => exec('bash -c "pavucontrol &"'), + command: () => execAsync(['swayosd-client', '--output-volume', 'mute-toggle']).catch(print), + secondaryCommand: () => execAsync(['bash', '-c', 'pavucontrol']).catch(print), icon: Icon({ className: 'grid-label', connections: [[Audio, icon => { @@ -163,8 +165,8 @@ const SecondRow = Box({ }), GridButton({ - command: () => exec("swayosd-client --input-volume mute-toggle"), - secondaryCommand: () => exec('bash -c "pavucontrol &"'), + command: () => execAsync(['swayosd-client', '--input-volume', 'mute-toggle']).catch(print), + secondaryCommand: () => execAsync(['bash', '-c', 'pavucontrol']).catch(print), icon: Icon({ className: 'grid-label', connections: [[Audio, icon => { @@ -186,11 +188,8 @@ const SecondRow = Box({ }), GridButton({ - command: () => exec('bash -c "$LOCK_PATH/lock.sh &"'), - secondaryCommand: () => { - ags.App.openWindow('closer'); - ags.App.openWindow('powermenu'); - }, + command: () => execAsync(['bash', '-c', '$LOCK_PATH/lock.sh']).catch(print), + secondaryCommand: () => openWindow('powermenu'), icon: Label({ className: 'grid-label', label: " 󰌾 ",