From 53eda996c9eed342e30d31c7a7a27e163fe47c60 Mon Sep 17 00:00:00 2001 From: matt1432 Date: Mon, 11 Sep 2023 19:57:21 -0400 Subject: [PATCH] feat(ags): reorder abstract js modules --- config/ags/config.js | 2 +- config/ags/js/bar/audio.js | 4 +++- config/ags/js/bar/bar.js | 2 +- config/ags/js/bar/battery.js | 3 ++- config/ags/js/bar/brightness.js | 2 +- config/ags/js/bar/heart.js | 2 +- config/ags/js/bar/notif-button.js | 3 ++- config/ags/js/bar/osk-toggle.js | 2 +- config/ags/js/bar/quick-settings.js | 3 ++- config/ags/js/bar/systray.js | 3 ++- config/ags/js/bar/tablet-toggle.js | 2 +- config/ags/js/bar/workspaces.js | 2 +- config/ags/js/misc/closer.js | 13 +++++++++++++ config/ags/js/{common.js => misc/cursorbox.js} | 18 ------------------ config/ags/js/misc/separator.js | 3 +++ config/ags/js/notifications/base.js | 2 +- config/ags/js/notifications/center.js | 5 +++-- 17 files changed, 38 insertions(+), 33 deletions(-) create mode 100644 config/ags/js/misc/closer.js rename config/ags/js/{common.js => misc/cursorbox.js} (56%) create mode 100644 config/ags/js/misc/separator.js diff --git a/config/ags/config.js b/config/ags/config.js index 73fa005..adaf961 100644 --- a/config/ags/config.js +++ b/config/ags/config.js @@ -3,7 +3,7 @@ import { Powermenu } from './js/powermenu.js'; import { Bar } from './js/bar/bar.js'; import { NotificationCenter } from './js/notifications/center.js'; import { NotificationsPopupList } from './js/notifications/popup.js' -import { Closer } from './js/common.js'; +import { Closer } from './js/misc/closer.js'; const scss = ags.App.configDir + '/scss/main.scss'; const css = ags.App.configDir + '/style.css'; diff --git a/config/ags/js/bar/audio.js b/config/ags/js/bar/audio.js index 2d62b76..62a00d0 100644 --- a/config/ags/js/bar/audio.js +++ b/config/ags/js/bar/audio.js @@ -1,6 +1,8 @@ const { Audio } = ags.Service; const { Label, Box, Icon, Stack, Button, Slider } = ags.Widget; -import { Separator, EventBox } from '../common.js'; + +import { Separator } from '../misc/separator.js'; +import { EventBox } from '../misc/cursorbox.js'; const items = { 101: 'audio-volume-overamplified-symbolic', diff --git a/config/ags/js/bar/bar.js b/config/ags/js/bar/bar.js index 7ecb27d..5ea0a92 100644 --- a/config/ags/js/bar/bar.js +++ b/config/ags/js/bar/bar.js @@ -1,6 +1,6 @@ const { Window, CenterBox, Box } = ags.Widget; -import { Separator } from '../common.js'; +import { Separator } from '../misc/separator.js'; import { CurrentWindow } from './current-window.js'; import { Workspaces } from './workspaces.js'; import { OskToggle } from './osk-toggle.js'; diff --git a/config/ags/js/bar/battery.js b/config/ags/js/bar/battery.js index 2e68aeb..297dfea 100644 --- a/config/ags/js/bar/battery.js +++ b/config/ags/js/bar/battery.js @@ -1,7 +1,8 @@ const { Label, Icon, Stack, ProgressBar, Overlay, Box } = ags.Widget; -import { Separator } from '../common.js'; const { exec } = ags.Utils; +import { Separator } from '../misc/separator.js'; + const icons = charging => ([ ...Array.from({ length: 10 }, (_, i) => i * 10).map(i => ([ `${i}`, Icon({ diff --git a/config/ags/js/bar/brightness.js b/config/ags/js/bar/brightness.js index da41f40..4c1a007 100644 --- a/config/ags/js/bar/brightness.js +++ b/config/ags/js/bar/brightness.js @@ -1,6 +1,6 @@ const { Label, Icon, Stack, ProgressBar, Overlay, Box } = ags.Widget; const { exec } = ags.Utils; -import { Separator } from '../common.js'; +import { Separator } from '../misc/separator.js'; import { Heart } from './heart.js'; export const Brightness = Overlay({ diff --git a/config/ags/js/bar/heart.js b/config/ags/js/bar/heart.js index 5b632e0..15f3f12 100644 --- a/config/ags/js/bar/heart.js +++ b/config/ags/js/bar/heart.js @@ -2,7 +2,7 @@ const { Box, Label } = ags.Widget; const { subprocess, exec } = ags.Utils; const deflisten = subprocess; -import { EventBox } from '../common.js'; +import { EventBox } from '../misc/cursorbox.js'; deflisten( ['bash', '-c', 'tail -f /home/matt/.config/.heart'], diff --git a/config/ags/js/bar/notif-button.js b/config/ags/js/bar/notif-button.js index e3290dc..25ab758 100644 --- a/config/ags/js/bar/notif-button.js +++ b/config/ags/js/bar/notif-button.js @@ -2,7 +2,8 @@ const { Box, Label, Icon } = ags.Widget; const { openWindow, closeWindow } = ags.App; const { Notifications } = ags.Service; -import { EventBox, Separator } from '../common.js'; +import { Separator } from '../misc/separator.js'; +import { EventBox } from '../misc/cursorbox.js'; var notifButtonState = false; diff --git a/config/ags/js/bar/osk-toggle.js b/config/ags/js/bar/osk-toggle.js index 16d801b..c29cbdc 100644 --- a/config/ags/js/bar/osk-toggle.js +++ b/config/ags/js/bar/osk-toggle.js @@ -2,7 +2,7 @@ const { Box, Label } = ags.Widget; const { subprocess, exec } = ags.Utils; const deflisten = subprocess; -import { EventBox } from '../common.js'; +import { EventBox } from '../misc/cursorbox.js'; deflisten( ['bash', '-c', '$AGS_PATH/osk-toggle.sh getState'], diff --git a/config/ags/js/bar/quick-settings.js b/config/ags/js/bar/quick-settings.js index c27c1ab..bc5ea3f 100644 --- a/config/ags/js/bar/quick-settings.js +++ b/config/ags/js/bar/quick-settings.js @@ -1,8 +1,9 @@ const { Box, Label } = ags.Widget; const { subprocess } = ags.Utils; -import { EventBox } from '../common.js'; const deflisten = subprocess; +import { EventBox } from '../misc/cursorbox.js'; + deflisten( ['bash', '-c', '$AGS_PATH/qs-toggle.sh state'], (output) => { diff --git a/config/ags/js/bar/systray.js b/config/ags/js/bar/systray.js index c15393c..b3d63f3 100644 --- a/config/ags/js/bar/systray.js +++ b/config/ags/js/bar/systray.js @@ -1,7 +1,8 @@ const { SystemTray } = ags.Service; const { Box, Button, Icon, MenuItem } = ags.Widget; const { Gtk } = imports.gi; -import { EventBox } from '../common.js'; + +import { EventBox } from '../misc/cursorbox.js'; const SysTrayItem = item => MenuItem({ className: 'tray-item', diff --git a/config/ags/js/bar/tablet-toggle.js b/config/ags/js/bar/tablet-toggle.js index 7572a8d..e1a09b7 100644 --- a/config/ags/js/bar/tablet-toggle.js +++ b/config/ags/js/bar/tablet-toggle.js @@ -1,7 +1,7 @@ const { Box, Label } = ags.Widget; const { subprocess } = ags.Utils; -import { EventBox } from '../common.js'; +import { EventBox } from '../misc/cursorbox.js'; export const TabletToggle = EventBox({ className: 'toggle-off', diff --git a/config/ags/js/bar/workspaces.js b/config/ags/js/bar/workspaces.js index fdeda63..fefa7e8 100644 --- a/config/ags/js/bar/workspaces.js +++ b/config/ags/js/bar/workspaces.js @@ -2,7 +2,7 @@ const { Hyprland, Applications } = ags.Service; const { execAsync } = ags.Utils; const { Box, Button, Label, Revealer } = ags.Widget; -import { EventBox } from '../common.js'; +import { EventBox } from '../misc/cursorbox.js'; const Workspace = ({ i } = {}) => Revealer({ diff --git a/config/ags/js/misc/closer.js b/config/ags/js/misc/closer.js new file mode 100644 index 0000000..a970805 --- /dev/null +++ b/config/ags/js/misc/closer.js @@ -0,0 +1,13 @@ +export const Closer = ags.Widget.Window({ + name: 'closer', + popup: true, + layer: 'top', + anchor: 'top bottom left right', + + child: ags.Widget.EventBox({ + onPrimaryClickRelease: () => { + ags.App.closeWindow('powermenu'); + ags.App.closeWindow('closer'); + }, + }), +}); diff --git a/config/ags/js/common.js b/config/ags/js/misc/cursorbox.js similarity index 56% rename from config/ags/js/common.js rename to config/ags/js/misc/cursorbox.js index bf43acb..399d73e 100644 --- a/config/ags/js/common.js +++ b/config/ags/js/misc/cursorbox.js @@ -1,21 +1,3 @@ -export const Closer = ags.Widget.Window({ - name: 'closer', - popup: true, - layer: 'top', - anchor: 'top bottom left right', - - child: ags.Widget.EventBox({ - onPrimaryClickRelease: () => { - ags.App.closeWindow('powermenu'); - ags.App.closeWindow('closer'); - }, - }), -}); - -export const Separator = width => ags.Widget.Box({ - style: `min-width: ${width}px;`, -}); - import Gdk from 'gi://Gdk'; const display = Gdk.Display.get_default(); diff --git a/config/ags/js/misc/separator.js b/config/ags/js/misc/separator.js new file mode 100644 index 0000000..8ade213 --- /dev/null +++ b/config/ags/js/misc/separator.js @@ -0,0 +1,3 @@ +export const Separator = width => ags.Widget.Box({ + style: `min-width: ${width}px;`, +}); diff --git a/config/ags/js/notifications/base.js b/config/ags/js/notifications/base.js index 60c807a..5abba85 100644 --- a/config/ags/js/notifications/base.js +++ b/config/ags/js/notifications/base.js @@ -4,7 +4,7 @@ const { lookUpIcon, timeout } = ags.Utils; const { Box, Icon, Label, Button } = ags.Widget; import { Draggable } from '../misc/drag.js'; -import { EventBox } from '../common.js' +import { EventBox } from '../misc/cursorbox.js' const NotificationIcon = ({ appEntry, appIcon, image }) => { if (image) { diff --git a/config/ags/js/notifications/center.js b/config/ags/js/notifications/center.js index 2c3c943..6aff675 100644 --- a/config/ags/js/notifications/center.js +++ b/config/ags/js/notifications/center.js @@ -1,8 +1,9 @@ -import Notification from './base.js'; -import { EventBox } from '../common.js' const { Notifications } = ags.Service; const { Button, Label, Box, Icon, Scrollable, Window } = ags.Widget; +import Notification from './base.js'; +import { EventBox } from '../misc/cursorbox.js' + const ClearButton = () => EventBox({child: Button({ onClicked: Notifications.clear, connections: [[Notifications, button => {