nixos-configs/config/ags/traybuttons/traybuttons.js

147 lines
3.4 KiB
JavaScript
Raw Normal View History

2023-08-28 00:01:16 -04:00
import Gdk from 'gi://Gdk';
const display = Gdk.Display.get_default();
import { CurrentWindow } from 'file:///home/matt/.nix/config/ags/current-window/current-window.js';
2023-09-04 00:41:14 -04:00
import { Workspaces } from 'file:///home/matt/.nix/config/ags/workspaces/workspaces.js';
2023-08-28 00:01:16 -04:00
const Separator = () => ags.Widget.Box({
2023-09-04 00:41:14 -04:00
style: 'min-width: 12px;',
2023-08-28 00:01:16 -04:00
});
ags.Utils.subprocess(
['bash', '-c', '/home/matt/.nix/config/ags/scripts/osk-toggle.sh getState'],
(output) => {
if (output == 'Running') {
OskToggle.toggleClassName('toggle-on', true);
} else {
OskToggle.toggleClassName('toggle-on', false);
}
},
);
2023-08-27 14:28:39 -04:00
const OskToggle = ags.Widget.EventBox({
className: 'toggle-off',
onPrimaryClickRelease: function() {
2023-08-28 00:01:16 -04:00
ags.Utils.subprocess(
['bash', '-c', '/home/matt/.nix/config/ags/scripts/osk-toggle.sh toggle'],
(output) => {
if (output == 'Running') {
OskToggle.toggleClassName('toggle-on', false);
} else {
OskToggle.toggleClassName('toggle-on', true);
}
},
);
},
onHover: box => {
box.window.set_cursor(Gdk.Cursor.new_from_name(display, 'pointer'));
},
onHoverLost: box => {
box.window.set_cursor(null);
2023-08-27 14:28:39 -04:00
},
child: ags.Widget.Box({
className: 'osk-toggle',
vertical: false,
2023-08-28 00:01:16 -04:00
children: [
ags.Widget.Label({
label: " 󰌌 ",
}),
],
}),
});
ags.Utils.subprocess(
['bash', '-c', 'tail -f /home/matt/.config/.heart'],
(output) => {
HeartToggle.child.children[0].label = ' ' + output;
if (output == '󰣐') {
HeartToggle.toggleClassName('toggle-on', true);
} else {
HeartToggle.toggleClassName('toggle-on', false);
}
},
);
const HeartToggle = ags.Widget.EventBox({
className: 'toggle-off',
halign: 'center',
onPrimaryClickRelease: function() {
ags.Utils.exec('/home/matt/.nix/config/ags/scripts/heart.sh toggle');
},
onHover: box => {
box.window.set_cursor(Gdk.Cursor.new_from_name(display, 'pointer'));
},
onHoverLost: box => {
box.window.set_cursor(null);
},
child: ags.Widget.Box({
className: 'heart-toggle',
vertical: false,
2023-08-27 14:28:39 -04:00
child: ags.Widget.Label({
2023-08-28 00:01:16 -04:00
label: '',
2023-08-27 14:28:39 -04:00
}),
}),
});
export const LeftBar = ags.Widget.Window({
name: 'left-bar',
layer: 'overlay',
2023-08-28 00:01:16 -04:00
anchor: 'top left right',
exclusive: true,
2023-08-27 14:28:39 -04:00
2023-08-28 00:01:16 -04:00
child: ags.Widget.CenterBox({
2023-08-27 14:28:39 -04:00
className: 'transparent',
2023-08-28 00:01:16 -04:00
halign: 'fill',
style: 'margin-top: 5px; margin-left: 5px;',
2023-08-27 14:28:39 -04:00
vertical: false,
children: [
2023-08-28 00:01:16 -04:00
ags.Widget.Box({
halign: 'start',
children: [
2023-08-27 14:28:39 -04:00
2023-08-28 00:01:16 -04:00
OskToggle,
Separator(),
2023-08-27 14:28:39 -04:00
2023-08-28 00:01:16 -04:00
ags.Widget.EventBox({
className: 'toggle-off',
onPrimaryClickRelease: '',
onHover: box => {
box.window.set_cursor(Gdk.Cursor.new_from_name(display, 'pointer'));
},
onHoverLost: box => {
box.window.set_cursor(null);
},
child: ags.Widget.Box({
className: 'tablet-toggle',
vertical: false,
2023-08-27 14:28:39 -04:00
2023-08-28 00:01:16 -04:00
child: ags.Widget.Label({
label: " 󰦧 ",
}),
}),
2023-08-27 14:28:39 -04:00
}),
2023-08-28 00:01:16 -04:00
Separator(),
2023-08-27 14:28:39 -04:00
2023-08-28 00:01:16 -04:00
HeartToggle,
2023-08-27 14:28:39 -04:00
2023-09-04 00:41:14 -04:00
Separator(),
Workspaces(),
2023-08-28 00:01:16 -04:00
],
}),
2023-08-27 14:28:39 -04:00
CurrentWindow,
2023-08-27 14:28:39 -04:00
2023-08-28 00:01:16 -04:00
ags.Widget.Box({
halign: 'end',
style: 'background: red; min-width: 100px; min-height: 40px',
}),
2023-08-27 14:28:39 -04:00
],
}),
});