From 1c56347c6c5d9ef48da3e8c9e63082fd65289458 Mon Sep 17 00:00:00 2001 From: emanuel <76693837+emsquid@users.noreply.github.com> Date: Mon, 23 Dec 2024 13:28:56 +0100 Subject: [PATCH 01/10] nix: fix unsupportedSystem for gpu-screen-recorder --- flake.nix | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/flake.nix b/flake.nix index 681ac53..10be858 100644 --- a/flake.nix +++ b/flake.nix @@ -49,7 +49,6 @@ pkgs.glib pkgs.bluez-tools pkgs.grimblast - pkgs.gpu-screen-recorder pkgs.brightnessctl pkgs.gnome-bluetooth (pkgs.python3.withPackages (python-pkgs: with python-pkgs; [ @@ -67,7 +66,7 @@ pkgs.gvfs pkgs.swww pkgs.pywal - ]; + ] ++ (nixpkgs.lib.optionals (system == "x86_64-linux") [pkgs.gpu-screen-recorder]); }; }); From d8a59c1d18e648bb639712a70f45c5c0ac85e3e0 Mon Sep 17 00:00:00 2001 From: Jas Singh Date: Tue, 24 Dec 2024 01:09:09 -0800 Subject: [PATCH 02/10] Fixed a bug that would prevent the workspace module from being scrolled. (#609) --- .../bar/modules/workspaces/helpers/index.ts | 2 +- .../bar/modules/workspaces/index.tsx | 25 +++++++++------- src/components/bar/shared/WidgetContainer.tsx | 6 ++-- .../menus/audio/active/sliderItem/Slider.tsx | 17 +++++------ src/lib/types/bar.d.ts | 2 +- src/lib/utils.ts | 30 +++++++++++++++++-- 6 files changed, 56 insertions(+), 26 deletions(-) diff --git a/src/components/bar/modules/workspaces/helpers/index.ts b/src/components/bar/modules/workspaces/helpers/index.ts index 8403117..fd20d2c 100644 --- a/src/components/bar/modules/workspaces/helpers/index.ts +++ b/src/components/bar/modules/workspaces/helpers/index.ts @@ -162,7 +162,7 @@ const navigateWorkspace = ( while (attempts < workspacesList.length) { const targetWS = workspacesList[newIndex]; if (!isWorkspaceIgnored(ignoredWorkspaces, targetWS)) { - hyprlandService.message_async(`dispatch workspace ${targetWS}`); + hyprlandService.dispatch('workspace', targetWS.toString()); return; } newIndex = (newIndex + step + workspacesList.length) % workspacesList.length; diff --git a/src/components/bar/modules/workspaces/index.tsx b/src/components/bar/modules/workspaces/index.tsx index 6940d8a..eeb7196 100644 --- a/src/components/bar/modules/workspaces/index.tsx +++ b/src/components/bar/modules/workspaces/index.tsx @@ -1,10 +1,11 @@ import options from 'src/options'; import { createThrottledScrollHandlers, getCurrentMonitorWorkspaces } from './helpers'; -import { BarBoxChild, SelfButton } from 'src/lib/types/bar'; +import { BarBoxChild } from 'src/lib/types/bar'; import { WorkspaceModule } from './workspaces'; import { bind, Variable } from 'astal'; import { GtkWidget } from 'src/lib/types/widget'; -import { Gdk } from 'astal/gtk3'; +import { Astal, Gdk } from 'astal/gtk3'; +import { isScrollDown, isScrollUp } from 'src/lib/utils'; const { workspaces, scroll_speed } = options.bar.workspaces; @@ -27,23 +28,27 @@ const Workspaces = (monitor = -1): BarBoxChild => { boxClass: 'workspaces', isBox: true, props: { - setup: (self: SelfButton): void => { + setup: (self: Astal.EventBox): void => { + let scrollHandlers: number; Variable.derive([bind(scroll_speed)], (scroll_speed) => { + if (scrollHandlers) { + self.disconnect(scrollHandlers); + } + const { throttledScrollUp, throttledScrollDown } = createThrottledScrollHandlers( scroll_speed, currentMonitorWorkspaces, ); - const scrollHandlers = self.connect('scroll-event', (_: GtkWidget, event: Gdk.Event) => { - const eventDirection = event.get_scroll_direction()[1]; - if (eventDirection === Gdk.ScrollDirection.UP) { - throttledScrollUp(); - } else if (eventDirection === Gdk.ScrollDirection.DOWN) { + scrollHandlers = self.connect('scroll-event', (_: GtkWidget, event: Gdk.Event) => { + if (isScrollUp(event)) { throttledScrollDown(); } - }); - self.disconnect(scrollHandlers); + if (isScrollDown(event)) { + throttledScrollUp(); + } + }); }); }, }, diff --git a/src/components/bar/shared/WidgetContainer.tsx b/src/components/bar/shared/WidgetContainer.tsx index 2c5d41c..9ed9a58 100644 --- a/src/components/bar/shared/WidgetContainer.tsx +++ b/src/components/bar/shared/WidgetContainer.tsx @@ -26,9 +26,9 @@ export const WidgetContainer = (child: BarBoxChild): JSX.Element => { if (child.isBox) { return ( - - {child.component} - + + {child.component} + ); } diff --git a/src/components/menus/audio/active/sliderItem/Slider.tsx b/src/components/menus/audio/active/sliderItem/Slider.tsx index cd4651e..07e50f1 100644 --- a/src/components/menus/audio/active/sliderItem/Slider.tsx +++ b/src/components/menus/audio/active/sliderItem/Slider.tsx @@ -1,7 +1,7 @@ import { bind } from 'astal'; import { Gdk, Gtk } from 'astal/gtk3'; import AstalWp from 'gi://AstalWp?version=0.1'; -import { capitalizeFirstLetter } from 'src/lib/utils'; +import { capitalizeFirstLetter, isScrollDown, isScrollUp } from 'src/lib/utils'; import options from 'src/options'; const { raiseMaximumVolume } = options.menus.volume; @@ -34,15 +34,14 @@ export const Slider = ({ device, type }: SliderProps): JSX.Element => { }} setup={(self) => { self.connect('scroll-event', (_, event: Gdk.Event) => { - const [directionSuccess, direction] = event.get_scroll_direction(); - const [deltasSuccess, , yScroll] = event.get_scroll_deltas(); + if (isScrollUp(event)) { + const newVolume = device.volume + 0.05; + device.set_volume(Math.min(newVolume, 1)); + } - if (directionSuccess) { - const newVolume = device.volume + (direction === Gdk.ScrollDirection.DOWN ? 0.05 : -0.05); - device.set_volume(Math.min(newVolume, 1)); - } else if (deltasSuccess) { - const newVolume = device.volume - yScroll / 100; - device.set_volume(Math.min(newVolume, 1)); + if (isScrollDown(event)) { + const newVolume = device.volume - 0.05; + device.set_volume(newVolume); } }); }} diff --git a/src/lib/types/bar.d.ts b/src/lib/types/bar.d.ts index adb3945..70c6082 100644 --- a/src/lib/types/bar.d.ts +++ b/src/lib/types/bar.d.ts @@ -13,7 +13,7 @@ export type BarBoxChild = { isBox?: boolean; boxClass: string; tooltip_text?: string | Binding; -} & ({ isBox: true; props: Widget.BoxProps } | { isBox?: false; props: Widget.ButtonProps }); +} & ({ isBox: true; props: Widget.EventBoxProps } | { isBox?: false; props: Widget.ButtonProps }); export type SelfButton = Button; diff --git a/src/lib/utils.ts b/src/lib/utils.ts index 55d3dc1..f599b77 100644 --- a/src/lib/utils.ts +++ b/src/lib/utils.ts @@ -399,7 +399,20 @@ export const isMiddleClick = (event: Astal.ClickEvent): boolean => event.button * * @returns True if the event is a scroll up, false otherwise. */ -export const isScrollUp = (event: Astal.ScrollEvent): boolean => event.direction === Gdk.ScrollDirection.UP; +export const isScrollUp = (event: Gdk.Event): boolean => { + const [directionSuccess, direction] = event.get_scroll_direction(); + const [deltaSuccess, , yScroll] = event.get_scroll_deltas(); + + if (directionSuccess && direction === Gdk.ScrollDirection.UP) { + return true; + } + + if (deltaSuccess && yScroll < 0) { + return true; + } + + return false; +}; /** * Checks if an event is a scroll down. @@ -410,4 +423,17 @@ export const isScrollUp = (event: Astal.ScrollEvent): boolean => event.direction * * @returns True if the event is a scroll down, false otherwise. */ -export const isScrollDown = (event: Astal.ScrollEvent): boolean => event.direction === Gdk.ScrollDirection.DOWN; +export const isScrollDown = (event: Gdk.Event): boolean => { + const [directionSuccess, direction] = event.get_scroll_direction(); + const [deltaSuccess, , yScroll] = event.get_scroll_deltas(); + + if (directionSuccess && direction === Gdk.ScrollDirection.DOWN) { + return true; + } + + if (deltaSuccess && yScroll > 0) { + return true; + } + + return false; +}; From a3f348c58015007c1813dd7bf4205ded47f3e57d Mon Sep 17 00:00:00 2001 From: Jas Singh Date: Tue, 24 Dec 2024 02:17:08 -0800 Subject: [PATCH 03/10] Fixed an issue that would caused empty dashboard shortcuts to not hide properly. (#610) --- .../shortcuts/buttons/ShortcutButtons.tsx | 28 +++++++++++++++++-- .../dashboard/shortcuts/sections/Column.tsx | 8 +++--- .../dashboard/shortcuts/sections/Section.tsx | 4 +-- src/components/osd/helpers.ts | 12 ++++++++ 4 files changed, 44 insertions(+), 8 deletions(-) diff --git a/src/components/menus/dashboard/shortcuts/buttons/ShortcutButtons.tsx b/src/components/menus/dashboard/shortcuts/buttons/ShortcutButtons.tsx index bbd8bca..5f99b56 100644 --- a/src/components/menus/dashboard/shortcuts/buttons/ShortcutButtons.tsx +++ b/src/components/menus/dashboard/shortcuts/buttons/ShortcutButtons.tsx @@ -24,36 +24,60 @@ const ShortcutButton = ({ shortcut, ...props }: ShortcutButtonProps): JSX.Elemen }; export const LeftShortcut1 = (): JSX.Element => { + if (!hasCommand(left.shortcut1)) { + return ; + } + return ( ); }; export const LeftShortcut2 = (): JSX.Element => { + if (!hasCommand(left.shortcut2)) { + return ; + } + return ; }; export const LeftShortcut3 = (): JSX.Element => { + if (!hasCommand(left.shortcut3)) { + return ; + } + return ( ); }; export const LeftShortcut4 = (): JSX.Element => { + if (!hasCommand(left.shortcut4)) { + return ; + } + return ; }; export const RightShortcut1 = (): JSX.Element => { + if (!hasCommand(right.shortcut1)) { + return ; + } + return ; }; export const RightShortcut3 = (): JSX.Element => { + if (!hasCommand(right.shortcut3)) { + return ; + } + return ; }; diff --git a/src/components/menus/dashboard/shortcuts/sections/Column.tsx b/src/components/menus/dashboard/shortcuts/sections/Column.tsx index 312ec1c..b969eb5 100644 --- a/src/components/menus/dashboard/shortcuts/sections/Column.tsx +++ b/src/components/menus/dashboard/shortcuts/sections/Column.tsx @@ -1,9 +1,9 @@ import { BindableChild } from 'astal/gtk3/astalify'; -export const LeftColumn = ({ visibleClass, children }: LeftColumnProps): JSX.Element => { +export const LeftColumn = ({ isVisible, children }: LeftColumnProps): JSX.Element => { return ( - - {visibleClass ? ( + + {isVisible ? ( {children} @@ -25,7 +25,7 @@ export const RightColumn = ({ children }: RightColumnProps): JSX.Element => { }; interface LeftColumnProps { - visibleClass?: boolean; + isVisible?: boolean; children?: BindableChild | BindableChild[]; } diff --git a/src/components/menus/dashboard/shortcuts/sections/Section.tsx b/src/components/menus/dashboard/shortcuts/sections/Section.tsx index edaf654..11489b4 100644 --- a/src/components/menus/dashboard/shortcuts/sections/Section.tsx +++ b/src/components/menus/dashboard/shortcuts/sections/Section.tsx @@ -57,7 +57,7 @@ export const LeftShortcuts = (): JSX.Element => { return ( - + @@ -78,7 +78,7 @@ export const RightShortcuts = (): JSX.Element => { {Variable.derive(rightBindings, () => { return ( - + diff --git a/src/components/osd/helpers.ts b/src/components/osd/helpers.ts index a467066..2899f44 100644 --- a/src/components/osd/helpers.ts +++ b/src/components/osd/helpers.ts @@ -8,6 +8,14 @@ const { enable, duration, active_monitor, monitor } = options.theme.osd; let count = 0; +/* + * So the OSD doesn't show on startup for no reason + */ +let isStartingUp = true; +timeout(3000, () => { + isStartingUp = false; +}); + /** * Handles the reveal state of a Widget.Revealer. * @@ -69,6 +77,10 @@ export const handleRevealWindow = (self: Widget.Window, property: 'revealChild' * @param property The property to check, either 'revealChild' or 'visible'. */ export const handleReveal = (self: Widget.Revealer | Widget.Window, property: 'revealChild' | 'visible'): void => { + if (isStartingUp) { + return; + } + if (self instanceof Widget.Revealer) { handleRevealRevealer(self, property); } else if (self instanceof Widget.Window) { From e0917ffb28fb958a4a92e0aff43f7f6701687b96 Mon Sep 17 00:00:00 2001 From: ilikestreet Date: Tue, 24 Dec 2024 18:34:56 +0800 Subject: [PATCH 04/10] =?UTF-8?q?feat:=20no=20update=20w/=20autohide=20opt?= =?UTF-8?q?ion=20&=20add=20option=20to=20swap=20netstat=20icon=20=E2=80=A6?= =?UTF-8?q?=20(#591)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: no update w/ autohide option & add option to swap netstat icon for up/down links * Update src/scss/style/bar/bar.scss * Update src/components/bar/shared/Module.tsx * Update src/components/bar/settings/config.tsx * Update src/options.ts * Apply suggestions from code review * move visibilty to updatesIcon func --------- Co-authored-by: Jas Singh --- src/components/bar/modules/netstat/index.tsx | 8 +++++--- src/components/bar/modules/updates/index.tsx | 4 ++++ src/components/bar/settings/config.tsx | 12 ++++++++++++ src/components/bar/shared/Module.tsx | 3 ++- src/lib/types/bar.d.ts | 1 + src/options.ts | 3 +++ 6 files changed, 27 insertions(+), 4 deletions(-) diff --git a/src/components/bar/modules/netstat/index.tsx b/src/components/bar/modules/netstat/index.tsx index 8a515e6..ae0f7f5 100644 --- a/src/components/bar/modules/netstat/index.tsx +++ b/src/components/bar/modules/netstat/index.tsx @@ -19,6 +19,8 @@ const { rateUnit, dynamicIcon, icon, + networkInLabel, + networkOutLabel, round, leftClick, rightClick, @@ -47,11 +49,11 @@ export const Netstat = (): BarBoxChild => { const renderNetworkLabel = (lblType: NetstatLabelType, networkService: NetworkResourceData): string => { switch (lblType) { case 'in': - return `↓ ${networkService.in}`; + return `${networkInLabel.get()} ${networkService.in}`; case 'out': - return `↑ ${networkService.out}`; + return `${networkOutLabel.get()} ${networkService.out}`; default: - return `↓ ${networkService.in} ↑ ${networkService.out}`; + return `${networkInLabel.get()} ${networkService.in} ${networkOutLabel.get()} ${networkService.out}`; } }; diff --git a/src/components/bar/modules/updates/index.tsx b/src/components/bar/modules/updates/index.tsx index 6887c17..d7307a3 100644 --- a/src/components/bar/modules/updates/index.tsx +++ b/src/components/bar/modules/updates/index.tsx @@ -10,6 +10,7 @@ const { updateCommand, label, padZero, + autoHide, pollingInterval, icon, leftClick, @@ -21,6 +22,7 @@ const { const pendingUpdates: Variable = Variable('0'); const postInputUpdater = Variable(true); +const isVis = Variable(!autoHide.get()); const processUpdateCount = (updateCount: string): string => { if (!padZero.get()) return updateCount; @@ -40,6 +42,7 @@ updatesPoller.initialize('updates'); const updatesIcon = Variable.derive( [bind(icon.pending), bind(icon.updated), bind(pendingUpdates)], (pendingIcon, updatedIcon, pUpdates) => { + isVis.set(!autoHide.get() || (autoHide.get() && parseFloat(pUpdates) > 0)); return parseFloat(pUpdates) === 0 ? updatedIcon : pendingIcon; }, ); @@ -49,6 +52,7 @@ export const Updates = (): BarBoxChild => { textIcon: updatesIcon(), tooltipText: bind(pendingUpdates).as((v) => `${v} updates available`), boxClass: 'updates', + isVis: isVis, label: bind(pendingUpdates), showLabelBinding: bind(label), props: { diff --git a/src/components/bar/settings/config.tsx b/src/components/bar/settings/config.tsx index e43fc37..384715e 100644 --- a/src/components/bar/settings/config.tsx +++ b/src/components/bar/settings/config.tsx @@ -154,6 +154,12 @@ export const CustomModuleSettings = (): JSX.Element => { />