Skip to content

Commit 27f2df3

Browse files
authored
Merge branch 'master' into patch-1
2 parents 1c56347 + 65140db commit 27f2df3

File tree

36 files changed

+540
-101
lines changed

36 files changed

+540
-101
lines changed

flake.nix

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,13 @@
7272

7373
# Define .overlay to expose the package as pkgs.hyprpanel based on the system
7474
overlay = final: prev: {
75-
hyprpanel = self.packages.${prev.stdenv.system}.default;
75+
hyprpanel = prev.writeShellScriptBin "hyprpanel" ''
76+
if [ "$#" -eq 0 ]; then
77+
exec ${self.packages.${final.stdenv.system}.default}/bin/hyprpanel
78+
else
79+
exec ${astal.packages.${final.stdenv.system}.io}/bin/astal -i hyprpanel "$@"
80+
fi
81+
'';
7682
};
7783
};
7884
}

scripts/checkUpdates.sh

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,19 @@
33
check_arch_updates() {
44
official_updates=0
55
aur_updates=0
6+
if command -v paru &> /dev/null; then
7+
aur_helper="paru"
8+
else
9+
aur_helper="yay"
10+
fi
611

712
if [ "$1" = "-y" ]; then
8-
aur_updates=$(yay -Qum 2>/dev/null | wc -l)
13+
aur_updates=$($aur_helper -Qum 2>/dev/null | wc -l)
914
elif [ "$1" = "-p" ]; then
1015
official_updates=$(checkupdates 2>/dev/null | wc -l)
1116
else
1217
official_updates=$(checkupdates 2>/dev/null | wc -l)
13-
aur_updates=$(yay -Qum 2>/dev/null | wc -l)
18+
aur_updates=$($aur_helper -Qum 2>/dev/null | wc -l)
1419
fi
1520

1621
total_updates=$((official_updates + aur_updates))

src/components/bar/modules/netstat/index.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ const {
1919
rateUnit,
2020
dynamicIcon,
2121
icon,
22+
networkInLabel,
23+
networkOutLabel,
2224
round,
2325
leftClick,
2426
rightClick,
@@ -47,11 +49,11 @@ export const Netstat = (): BarBoxChild => {
4749
const renderNetworkLabel = (lblType: NetstatLabelType, networkService: NetworkResourceData): string => {
4850
switch (lblType) {
4951
case 'in':
50-
return ` ${networkService.in}`;
52+
return `${networkInLabel.get()} ${networkService.in}`;
5153
case 'out':
52-
return ` ${networkService.out}`;
54+
return `${networkOutLabel.get()} ${networkService.out}`;
5355
default:
54-
return ` ${networkService.in} ${networkService.out}`;
56+
return `${networkInLabel.get()} ${networkService.in} ${networkOutLabel.get()} ${networkService.out}`;
5557
}
5658
};
5759

src/components/bar/modules/updates/index.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ const {
1010
updateCommand,
1111
label,
1212
padZero,
13+
autoHide,
1314
pollingInterval,
1415
icon,
1516
leftClick,
@@ -21,6 +22,7 @@ const {
2122

2223
const pendingUpdates: Variable<string> = Variable('0');
2324
const postInputUpdater = Variable(true);
25+
const isVis = Variable(!autoHide.get());
2426

2527
const processUpdateCount = (updateCount: string): string => {
2628
if (!padZero.get()) return updateCount;
@@ -37,9 +39,14 @@ const updatesPoller = new BashPoller<string, []>(
3739

3840
updatesPoller.initialize('updates');
3941

42+
Variable.derive([bind(autoHide)], (autoHideModule) => {
43+
isVis.set(!autoHideModule || (autoHideModule && parseFloat(pendingUpdates.get()) > 0));
44+
});
45+
4046
const updatesIcon = Variable.derive(
4147
[bind(icon.pending), bind(icon.updated), bind(pendingUpdates)],
4248
(pendingIcon, updatedIcon, pUpdates) => {
49+
isVis.set(!autoHide.get() || (autoHide.get() && parseFloat(pUpdates) > 0));
4350
return parseFloat(pUpdates) === 0 ? updatedIcon : pendingIcon;
4451
},
4552
);
@@ -49,6 +56,7 @@ export const Updates = (): BarBoxChild => {
4956
textIcon: updatesIcon(),
5057
tooltipText: bind(pendingUpdates).as((v) => `${v} updates available`),
5158
boxClass: 'updates',
59+
isVis: isVis,
5260
label: bind(pendingUpdates),
5361
showLabelBinding: bind(label),
5462
props: {

src/components/bar/modules/window_title/helpers/title.ts

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ import AstalHyprland from 'gi://AstalHyprland?version=0.1';
88
* This function searches for a matching window title in the predefined `windowTitleMap` based on the class of the provided window.
99
* If a match is found, it returns an object containing the icon and label for the window. If no match is found, it returns a default icon and label.
1010
*
11-
* @param windowtitle The window object containing the class information.
11+
* @param client The window object containing the class information.
1212
*
1313
* @returns An object containing the icon and label for the window.
1414
*/
15-
export const getWindowMatch = (windowtitle: AstalHyprland.Client): Record<string, string> => {
15+
export const getWindowMatch = (client: AstalHyprland.Client): Record<string, string> => {
1616
const windowTitleMap = [
1717
// user provided values
1818
...options.bar.windowtitle.title_map.get(),
@@ -119,17 +119,17 @@ export const getWindowMatch = (windowtitle: AstalHyprland.Client): Record<string
119119
['^$', '󰇄', 'Desktop'],
120120

121121
// Fallback icon
122-
['(.+)', '󰣆', `${capitalizeFirstLetter(windowtitle?.class ?? 'Unknown')}`],
122+
['(.+)', '󰣆', `${capitalizeFirstLetter(client?.class ?? 'Unknown')}`],
123123
];
124124

125-
if (!windowtitle?.class) {
125+
if (!client?.class) {
126126
return {
127127
icon: '󰇄',
128128
label: 'Desktop',
129129
};
130130
}
131131

132-
const foundMatch = windowTitleMap.find((wt) => RegExp(wt[0]).test(windowtitle?.class.toLowerCase()));
132+
const foundMatch = windowTitleMap.find((wt) => RegExp(wt[0]).test(client?.class.toLowerCase()));
133133

134134
if (!foundMatch || foundMatch.length !== 3) {
135135
return {
@@ -157,13 +157,12 @@ export const getWindowMatch = (windowtitle: AstalHyprland.Client): Record<string
157157
* @returns The title of the window as a string.
158158
*/
159159
export const getTitle = (client: AstalHyprland.Client, useCustomTitle: boolean, useClassName: boolean): string => {
160-
if (client === null) return getWindowMatch(client).label;
161-
162-
if (useCustomTitle) return getWindowMatch(client).label;
163-
if (useClassName) return client.class;
160+
if (client === null || useCustomTitle) return getWindowMatch(client).label;
164161

165162
const title = client.title;
166-
// If the title is empty or only filled with spaces, fallback to the class name
163+
164+
if (!title || useClassName) return client.class;
165+
167166
if (title.length === 0 || title.match(/^ *$/)) {
168167
return client.class;
169168
}

src/components/bar/modules/workspaces/helpers/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ const navigateWorkspace = (
162162
while (attempts < workspacesList.length) {
163163
const targetWS = workspacesList[newIndex];
164164
if (!isWorkspaceIgnored(ignoredWorkspaces, targetWS)) {
165-
hyprlandService.message_async(`dispatch workspace ${targetWS}`);
165+
hyprlandService.dispatch('workspace', targetWS.toString());
166166
return;
167167
}
168168
newIndex = (newIndex + step + workspacesList.length) % workspacesList.length;

src/components/bar/modules/workspaces/index.tsx

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import options from 'src/options';
22
import { createThrottledScrollHandlers, getCurrentMonitorWorkspaces } from './helpers';
3-
import { BarBoxChild, SelfButton } from 'src/lib/types/bar';
3+
import { BarBoxChild } from 'src/lib/types/bar';
44
import { WorkspaceModule } from './workspaces';
55
import { bind, Variable } from 'astal';
66
import { GtkWidget } from 'src/lib/types/widget';
7-
import { Gdk } from 'astal/gtk3';
7+
import { Astal, Gdk } from 'astal/gtk3';
8+
import { isScrollDown, isScrollUp } from 'src/lib/utils';
89

910
const { workspaces, scroll_speed } = options.bar.workspaces;
1011

@@ -27,23 +28,27 @@ const Workspaces = (monitor = -1): BarBoxChild => {
2728
boxClass: 'workspaces',
2829
isBox: true,
2930
props: {
30-
setup: (self: SelfButton): void => {
31+
setup: (self: Astal.EventBox): void => {
32+
let scrollHandlers: number;
3133
Variable.derive([bind(scroll_speed)], (scroll_speed) => {
34+
if (scrollHandlers) {
35+
self.disconnect(scrollHandlers);
36+
}
37+
3238
const { throttledScrollUp, throttledScrollDown } = createThrottledScrollHandlers(
3339
scroll_speed,
3440
currentMonitorWorkspaces,
3541
);
3642

37-
const scrollHandlers = self.connect('scroll-event', (_: GtkWidget, event: Gdk.Event) => {
38-
const eventDirection = event.get_scroll_direction()[1];
39-
if (eventDirection === Gdk.ScrollDirection.UP) {
40-
throttledScrollUp();
41-
} else if (eventDirection === Gdk.ScrollDirection.DOWN) {
43+
scrollHandlers = self.connect('scroll-event', (_: GtkWidget, event: Gdk.Event) => {
44+
if (isScrollUp(event)) {
4245
throttledScrollDown();
4346
}
44-
});
4547

46-
self.disconnect(scrollHandlers);
48+
if (isScrollDown(event)) {
49+
throttledScrollUp();
50+
}
51+
});
4752
});
4853
},
4954
},

src/components/bar/modules/workspaces/workspaces.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ export const WorkspaceModule = ({ monitor }: WorkspaceModuleProps): JSX.Element
152152
self.toggleClassName('active', activeWorkspace === wsId);
153153
self.toggleClassName(
154154
'occupied',
155-
(hyprlandService.get_workspace(wsId)?.get_clients().length || 0) > 0,
155+
(hyprlandService.get_workspace(wsId)?.get_clients()?.length || 0) > 0,
156156
);
157157
}}
158158
/>

src/components/bar/settings/config.tsx

Lines changed: 90 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,10 @@ export const CustomModuleSettings = (): JSX.Element => {
140140
<Option
141141
opt={options.bar.customModules.netstat.networkInterface}
142142
title="Network Interface"
143-
subtitle="Wiki: https://hyprpanel.com/configuration/panel.html#custom-modules"
143+
subtitle={
144+
'Name of the network interface to poll.\n' +
145+
"HINT: Get a list of interfaces with 'cat /proc/net/dev"
146+
}
144147
type="string"
145148
/>
146149
<Option
@@ -151,6 +154,12 @@ export const CustomModuleSettings = (): JSX.Element => {
151154
/>
152155
<Option opt={options.bar.customModules.netstat.icon} title="Netstat Icon" type="string" />
153156
<Option opt={options.bar.customModules.netstat.label} title="Show Label" type="boolean" />
157+
<Option opt={options.bar.customModules.netstat.networkInLabel} title="Network In Label" type="string" />
158+
<Option
159+
opt={options.bar.customModules.netstat.networkOutLabel}
160+
title="Network Out Label"
161+
type="string"
162+
/>
154163
<Option
155164
opt={options.bar.customModules.netstat.rateUnit}
156165
title="Rate Unit"
@@ -167,7 +176,7 @@ export const CustomModuleSettings = (): JSX.Element => {
167176
<Option opt={options.bar.customModules.netstat.round} title="Round" type="boolean" />
168177
<Option
169178
opt={options.bar.customModules.netstat.pollingInterval}
170-
title="Polling Interval"
179+
title="Polling Interval (ms)"
171180
type="number"
172181
min={100}
173182
max={60 * 24 * 1000}
@@ -218,6 +227,12 @@ export const CustomModuleSettings = (): JSX.Element => {
218227
/>
219228
<Option opt={options.bar.customModules.updates.icon.updated} title="No Updates Icon" type="string" />
220229
<Option opt={options.bar.customModules.updates.label} title="Show Label" type="boolean" />
230+
<Option
231+
opt={options.bar.customModules.updates.autoHide}
232+
title="Auto Hide"
233+
subtitle="Hides module when no updates are available."
234+
type="boolean"
235+
/>
221236
<Option opt={options.bar.customModules.updates.padZero} title="Pad with 0" type="boolean" />
222237
<Option opt={options.theme.bar.buttons.modules.updates.spacing} title="Spacing" type="string" />
223238
<Option
@@ -280,6 +295,79 @@ export const CustomModuleSettings = (): JSX.Element => {
280295
<Option opt={options.bar.customModules.weather.middleClick} title="Middle Click" type="string" />
281296
<Option opt={options.bar.customModules.weather.scrollUp} title="Scroll Up" type="string" />
282297
<Option opt={options.bar.customModules.weather.scrollDown} title="Scroll Down" type="string" />
298+
299+
{/* Hyprsunset Section */}
300+
<Header title="Hyprsunset" />
301+
<Option
302+
opt={options.bar.customModules.hyprsunset.temperature}
303+
title="Temperature"
304+
subtitle="Ex: 1000k, 2000k, 5000k, etc."
305+
type="string"
306+
/>
307+
<Option
308+
opt={options.theme.bar.buttons.modules.hyprsunset.enableBorder}
309+
title="Button Border"
310+
type="boolean"
311+
/>
312+
<Option opt={options.bar.customModules.hyprsunset.onIcon} title="Enabled Icon" type="string" />
313+
<Option opt={options.bar.customModules.hyprsunset.offIcon} title="Disabled Icon" type="string" />
314+
<Option opt={options.bar.customModules.hyprsunset.onLabel} title="Enabled Label" type="string" />
315+
<Option opt={options.bar.customModules.hyprsunset.offLabel} title="Disabled Label" type="string" />
316+
<Option opt={options.bar.customModules.hyprsunset.label} title="Show Label" type="boolean" />
317+
<Option opt={options.theme.bar.buttons.modules.hyprsunset.spacing} title="Spacing" type="string" />
318+
<Option
319+
opt={options.bar.customModules.hyprsunset.pollingInterval}
320+
title="Polling Interval"
321+
type="number"
322+
min={100}
323+
max={60 * 24 * 1000}
324+
increment={1000}
325+
/>
326+
<Option opt={options.bar.customModules.hyprsunset.rightClick} title="Right Click" type="string" />
327+
<Option opt={options.bar.customModules.hyprsunset.middleClick} title="Middle Click" type="string" />
328+
<Option opt={options.bar.customModules.hyprsunset.scrollUp} title="Scroll Up" type="string" />
329+
<Option opt={options.bar.customModules.hyprsunset.scrollDown} title="Scroll Down" type="string" />
330+
331+
{/* Hypridle Section */}
332+
<Header title="Hypridle" />
333+
<Option
334+
opt={options.theme.bar.buttons.modules.hypridle.enableBorder}
335+
title="Button Border"
336+
type="boolean"
337+
/>
338+
<Option opt={options.bar.customModules.hypridle.onIcon} title="Enabled Icon" type="string" />
339+
<Option opt={options.bar.customModules.hypridle.offIcon} title="Disabled Icon" type="string" />
340+
<Option opt={options.bar.customModules.hypridle.onLabel} title="Enabled Label" type="string" />
341+
<Option opt={options.bar.customModules.hypridle.offLabel} title="Disabled Label" type="string" />
342+
<Option opt={options.bar.customModules.hypridle.label} title="Show Label" type="boolean" />
343+
<Option opt={options.theme.bar.buttons.modules.hypridle.spacing} title="Spacing" type="string" />
344+
<Option
345+
opt={options.bar.customModules.hypridle.pollingInterval}
346+
title="Polling Interval"
347+
type="number"
348+
min={100}
349+
max={60 * 24 * 1000}
350+
increment={1000}
351+
/>
352+
<Option opt={options.bar.customModules.hypridle.rightClick} title="Right Click" type="string" />
353+
<Option opt={options.bar.customModules.hypridle.middleClick} title="Middle Click" type="string" />
354+
<Option opt={options.bar.customModules.hypridle.scrollUp} title="Scroll Up" type="string" />
355+
<Option opt={options.bar.customModules.hypridle.scrollDown} title="Scroll Down" type="string" />
356+
357+
{/* Power Section */}
358+
<Header title="Power" />
359+
<Option
360+
opt={options.theme.bar.buttons.modules.power.enableBorder}
361+
title="Button Border"
362+
type="boolean"
363+
/>
364+
<Option opt={options.theme.bar.buttons.modules.power.spacing} title="Spacing" type="string" />
365+
<Option opt={options.bar.customModules.power.icon} title="Power Button Icon" type="string" />
366+
<Option opt={options.bar.customModules.power.leftClick} title="Left Click" type="string" />
367+
<Option opt={options.bar.customModules.power.rightClick} title="Right Click" type="string" />
368+
<Option opt={options.bar.customModules.power.middleClick} title="Middle Click" type="string" />
369+
<Option opt={options.bar.customModules.power.scrollUp} title="Scroll Up" type="string" />
370+
<Option opt={options.bar.customModules.power.scrollDown} title="Scroll Down" type="string" />
283371
</box>
284372
</scrollable>
285373
);

0 commit comments

Comments
 (0)