diff --git a/config/ags/bin/notif-toggle.sh b/config/ags/bin/notif-toggle.sh new file mode 100755 index 00000000..60298a99 --- /dev/null +++ b/config/ags/bin/notif-toggle.sh @@ -0,0 +1,49 @@ +#!/usr/bin/env bash + +on () { + swaync-client -op + + eww open closer-notif1 + eww open closer-notif2 + eww open closer-notif3 + eww open closer-notif4 + + eww update notif-panel-state=true +} + +off () { + swaync-client -cp + + eww update notif-panel-state=false + + eww close closer-notif1 + eww close closer-notif2 + eww close closer-notif3 + eww close closer-notif4 +} + +toggle() { + if [[ $(eww get notif-panel-state) == "true" ]]; then + echo "Off" + off > /dev/null + else + echo "On" + on > /dev/null + fi +} + +state() { + if [[ $(eww get notif-panel-state) == "true" ]]; then + echo "Off" + else + echo "On" + fi +} + +[[ "$1" == "toggle" ]] && toggle +if [[ "$1" == "state" ]]; then + while true; do + state + sleep 1 + done +fi diff --git a/config/ags/bin/notif.sh b/config/ags/bin/notif.sh new file mode 100755 index 00000000..a986143c --- /dev/null +++ b/config/ags/bin/notif.sh @@ -0,0 +1,30 @@ +#!/usr/bin/env bash + +state () { + if [[ $(hyprctl layers | grep swaync-control-center) == "" ]]; then + if [[ $(eww get notif-panel-state) == "true" ]]; then + eww update notif-panel-state=false + fi + fi +} + +icon () { + COUNT=$(swaync-client -c) + + if [[ $(swaync-client -D) == "true" ]]; then + echo " 󱏨" + elif [[ $COUNT == "0" ]]; then + echo "$COUNT 󰂜" + else + echo "$COUNT 󰂚" + fi + state +} + +if [[ $1 == "icon" ]]; then + while true; do + sleep 0.01 + icon + done +fi + diff --git a/config/ags/bin/qs-toggle.sh b/config/ags/bin/qs-toggle.sh new file mode 100755 index 00000000..114907f5 --- /dev/null +++ b/config/ags/bin/qs-toggle.sh @@ -0,0 +1,39 @@ +#!/usr/bin/env bash + +on () { + eww open closer && + + eww open quick-settings-reveal; + eww update showqs=true; +} + +off () { + eww update showqs=false; + eww close quick-settings-reveal; +} + +toggle() { + if [[ $(eww get showqs) == "true" ]]; then + echo "Off" + off > /dev/null + else + echo "On" + on > /dev/null + fi +} + +state() { + if [[ $(eww get showqs) == "true" ]]; then + echo "Off" + else + echo "On" + fi +} + +[[ "$1" == "toggle" ]] && toggle +if [[ "$1" == "state" ]]; then + while true; do + state + sleep 1 + done +fi diff --git a/config/ags/js/bar/bar.js b/config/ags/js/bar/bar.js index 3f07f556..67eca85c 100644 --- a/config/ags/js/bar/bar.js +++ b/config/ags/js/bar/bar.js @@ -7,6 +7,7 @@ import { OskToggle } from './osk-toggle.js'; import { Heart } from './heart.js'; import { TabletToggle } from './tablet-toggle.js'; import { QsToggle } from './quick-settings.js'; +import { NotifButton } from './notif-button.js'; export const Bar = Window({ name: 'left-bar', @@ -51,6 +52,10 @@ export const Bar = Window({ Box({ halign: 'end', children: [ + NotifButton, + + Separator(12), + QsToggle, ], }), diff --git a/config/ags/js/bar/notif-button.js b/config/ags/js/bar/notif-button.js new file mode 100644 index 00000000..dd9ee146 --- /dev/null +++ b/config/ags/js/bar/notif-button.js @@ -0,0 +1,45 @@ +const { Box, Label } = ags.Widget; +const { subprocess } = ags.Utils; +import { EventBox } from '../common.js'; +const deflisten = subprocess; + +deflisten( + ['bash', '-c', '/home/matt/.nix/config/ags/bin/notif.sh icon'], + (output) => { + NotifButton.child.children[0].label = ' ' + output; + }, +); +deflisten( + ['bash', '-c', '/home/matt/.nix/config/ags/bin/notif-toggle.sh state'], + (output) => { + print(output) + if (output == 'On') { + NotifButton.toggleClassName('toggle-on', false); + } else { + NotifButton.toggleClassName('toggle-on', true); + } + }, +); +export const NotifButton = EventBox({ + className: 'toggle-off', + onPrimaryClickRelease: function() { + subprocess( + ['bash', '-c', '/home/matt/.nix/config/ags/bin/notif-toggle.sh toggle'], + (output) => { + print(output) + if (output == 'On') { + NotifButton.toggleClassName('toggle-on', true); + } else { + NotifButton.toggleClassName('toggle-on', false); + } + }, + ); + }, + child: Box({ + className: 'notif-panel', + vertical: false, + child: Label({ + label: "", + }), + }), +}); diff --git a/config/ags/js/bar/quick-settings.js b/config/ags/js/bar/quick-settings.js new file mode 100644 index 00000000..18ea78e9 --- /dev/null +++ b/config/ags/js/bar/quick-settings.js @@ -0,0 +1,39 @@ +const { Box, Label } = ags.Widget; +const { subprocess } = ags.Utils; +import { EventBox } from '../common.js'; +const deflisten = subprocess; + +deflisten( + ['bash', '-c', '/home/matt/.nix/config/ags/bin/qs-toggle.sh state'], + (output) => { + print(output) + if (output == 'On') { + QsToggle.toggleClassName('toggle-on', false); + } else { + QsToggle.toggleClassName('toggle-on', true); + } + }, +); +export const QsToggle = EventBox({ + className: 'toggle-off', + onPrimaryClickRelease: function() { + subprocess( + ['bash', '-c', '/home/matt/.nix/config/ags/bin/qs-toggle.sh toggle'], + (output) => { + print(output) + if (output == 'On') { + QsToggle.toggleClassName('toggle-on', true); + } else { + QsToggle.toggleClassName('toggle-on', false); + } + }, + ); + }, + child: Box({ + className: 'quick-settings-toggle', + vertical: false, + child: Label({ + label: "  ", + }), + }), +}); diff --git a/config/eww/closer/closer.yuck b/config/eww/closer/closer.yuck index da48c12d..e9cd242c 100644 --- a/config/eww/closer/closer.yuck +++ b/config/eww/closer/closer.yuck @@ -1,5 +1,5 @@ (defwidget closer [] - (eventbox :onclick "$EWW_PATH/close-opened.sh && eww close closer") + (eventbox :onclick "$EWW_PATH/close-opened.sh && eww close closer; eww update showqs=false") ) (defwindow closer :monitor 0 :geometry (geometry :width "100%"