feat(ags): close all windows when closing from button

This commit is contained in:
matt1432 2023-09-12 14:42:53 -04:00
parent 45ddea2a96
commit 2a540b0a62
6 changed files with 29 additions and 68 deletions

View file

@ -1,37 +0,0 @@
#!/usr/bin/env bash
on () {
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

View file

@ -3,6 +3,7 @@ const { toggleWindow, openWindow } = ags.App;
const { DateTime } = imports.gi.GLib; const { DateTime } = imports.gi.GLib;
import { EventBox } from '../misc/cursorbox.js'; import { EventBox } from '../misc/cursorbox.js';
import { closeAll } from '../misc/close-all.js';
const ClockModule = ({ const ClockModule = ({
interval = 1000, interval = 1000,
@ -30,6 +31,7 @@ export const Clock = EventBox({
} }
else { else {
Clock.toggleClassName('toggle-on', false); Clock.toggleClassName('toggle-on', false);
closeAll();
} }
} }
}], }],

View file

@ -4,6 +4,7 @@ const { Notifications } = ags.Service;
import { Separator } from '../misc/separator.js'; import { Separator } from '../misc/separator.js';
import { EventBox } from '../misc/cursorbox.js'; import { EventBox } from '../misc/cursorbox.js';
import { closeAll } from '../misc/close-all.js';
export const NotifButton = EventBox({ export const NotifButton = EventBox({
className: 'toggle-off', className: 'toggle-off',
@ -17,6 +18,7 @@ export const NotifButton = EventBox({
} }
else { else {
NotifButton.toggleClassName('toggle-on', false); NotifButton.toggleClassName('toggle-on', false);
closeAll();
} }
} }
}], }],

View file

@ -1,35 +1,26 @@
const { Box, Label } = ags.Widget; const { Box, Label } = ags.Widget;
const { subprocess } = ags.Utils; const { toggleWindow, openWindow } = ags.App;
const deflisten = subprocess;
import { EventBox } from '../misc/cursorbox.js'; import { EventBox } from '../misc/cursorbox.js';
import { closeAll } from '../misc/close-all.js';
deflisten(
['bash', '-c', '$AGS_PATH/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({ export const QsToggle = EventBox({
className: 'toggle-off', className: 'toggle-off',
onPrimaryClickRelease: function() { onPrimaryClickRelease: () => toggleWindow('quick-settings'),
subprocess( connections: [
['bash', '-c', '$AGS_PATH/qs-toggle.sh toggle'], [ags.App, (box, windowName, visible) => {
(output) => { if (windowName == 'quick-settings') {
print(output) if (visible) {
if (output == 'On') {
QsToggle.toggleClassName('toggle-on', true); QsToggle.toggleClassName('toggle-on', true);
} else { openWindow('closer');
QsToggle.toggleClassName('toggle-on', false);
} }
}, else {
); QsToggle.toggleClassName('toggle-on', false);
}, closeAll();
}
}
}],
],
child: Box({ child: Box({
className: 'quick-settings-toggle', className: 'quick-settings-toggle',
vertical: false, vertical: false,

View file

@ -0,0 +1,6 @@
export const closeAll = () => {
ags.App.windows.forEach(w => {
if (w.name != 'bar')
ags.App.closeWindow(w.name)
});
};

View file

@ -1,5 +1,7 @@
const { Window, EventBox } = ags.Widget; const { Window, EventBox } = ags.Widget;
const { windows, closeWindow } = ags.App; const { closeWindow } = ags.App;
import { closeAll } from './close-all.js';
export const Closer = Window({ export const Closer = Window({
name: 'closer', name: 'closer',
@ -8,11 +10,6 @@ export const Closer = Window({
anchor: 'top bottom left right', anchor: 'top bottom left right',
child: EventBox({ child: EventBox({
onPrimaryClickRelease: () => { onPrimaryClickRelease: () => closeAll(),
windows.forEach(w => {
if (w.name != 'bar')
closeWindow(w.name)
});
},
}), }),
}); });