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;
import { EventBox } from '../misc/cursorbox.js';
import { closeAll } from '../misc/close-all.js';
const ClockModule = ({
interval = 1000,
@ -30,6 +31,7 @@ export const Clock = EventBox({
}
else {
Clock.toggleClassName('toggle-on', false);
closeAll();
}
}
}],

View file

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

View file

@ -1,35 +1,26 @@
const { Box, Label } = ags.Widget;
const { subprocess } = ags.Utils;
const deflisten = subprocess;
const { toggleWindow, openWindow } = ags.App;
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({
className: 'toggle-off',
onPrimaryClickRelease: function() {
subprocess(
['bash', '-c', '$AGS_PATH/qs-toggle.sh toggle'],
(output) => {
print(output)
if (output == 'On') {
onPrimaryClickRelease: () => toggleWindow('quick-settings'),
connections: [
[ags.App, (box, windowName, visible) => {
if (windowName == 'quick-settings') {
if (visible) {
QsToggle.toggleClassName('toggle-on', true);
} else {
QsToggle.toggleClassName('toggle-on', false);
openWindow('closer');
}
},
);
},
else {
QsToggle.toggleClassName('toggle-on', false);
closeAll();
}
}
}],
],
child: Box({
className: 'quick-settings-toggle',
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 { windows, closeWindow } = ags.App;
const { closeWindow } = ags.App;
import { closeAll } from './close-all.js';
export const Closer = Window({
name: 'closer',
@ -8,11 +10,6 @@ export const Closer = Window({
anchor: 'top bottom left right',
child: EventBox({
onPrimaryClickRelease: () => {
windows.forEach(w => {
if (w.name != 'bar')
closeWindow(w.name)
});
},
onPrimaryClickRelease: () => closeAll(),
}),
});