-
-
Notifications
You must be signed in to change notification settings - Fork 15k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
hyprpanel: init at unstable-2025-02-17
- Loading branch information
1 parent
d21dc08
commit 8bfb068
Showing
2 changed files
with
353 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
{ | ||
lib, | ||
config, | ||
ags, | ||
astal, | ||
bluez, | ||
bluez-tools, | ||
brightnessctl, | ||
btop, | ||
dart-sass, | ||
fetchFromGitHub, | ||
fetchpatch2, | ||
glib, | ||
gnome-bluetooth, | ||
gpu-screen-recorder, | ||
gpustat, | ||
grimblast, | ||
gvfs, | ||
hyprpicker, | ||
libgtop, | ||
libnotify, | ||
matugen, | ||
networkmanager, | ||
python3, | ||
pywal, | ||
stdenv, | ||
swww, | ||
upower, | ||
wireplumber, | ||
wl-clipboard, | ||
writeShellScript, | ||
|
||
enableCuda ? config.cudaSupport, | ||
}: | ||
ags.bundle { | ||
pname = "hyprpanel"; | ||
version = "unstable-2025-02-17"; | ||
|
||
__structuredAttrs = true; | ||
strictDeps = true; | ||
|
||
src = fetchFromGitHub { | ||
owner = "Jas-SinghFSU"; | ||
repo = "HyprPanel"; | ||
rev = "9b342341fe17e4fb2c4cad9e3379a814a6a73097"; | ||
hash = "sha256-OQS2yhBYJZPvxkPGEx9FqT+voXTDm0UJDknCBBWgroo="; | ||
}; | ||
|
||
patches = [ | ||
# please merge https://github.com/NixOS/nixpkgs/pull/374302 | ||
./remove-tray.patch | ||
]; | ||
|
||
# keep in sync with https://github.com/Jas-SinghFSU/HyprPanel/blob/master/flake.nix#L28 | ||
dependencies = [ | ||
astal.apps | ||
astal.battery | ||
astal.bluetooth | ||
astal.cava | ||
astal.hyprland | ||
astal.mpris | ||
astal.network | ||
astal.notifd | ||
astal.powerprofiles | ||
# https://github.com/NixOS/nixpkgs/pull/374302 | ||
# astal.tray | ||
astal.wireplumber | ||
|
||
bluez | ||
bluez-tools | ||
brightnessctl | ||
btop | ||
dart-sass | ||
glib | ||
gnome-bluetooth | ||
grimblast | ||
gvfs | ||
hyprpicker | ||
libgtop | ||
libnotify | ||
matugen | ||
networkmanager | ||
pywal | ||
swww | ||
upower | ||
wireplumber | ||
wl-clipboard | ||
(python3.withPackages ( | ||
ps: | ||
with ps; | ||
[ | ||
dbus-python | ||
pygobject3 | ||
] | ||
++ lib.optional enableCuda gpustat | ||
)) | ||
] ++ (lib.optionals (stdenv.hostPlatform.system == "x86_64-linux") [ gpu-screen-recorder ]); | ||
|
||
# NOTE: no update script as dependencies must be kept in sync with upstream | ||
# and it is problematic to do it in an update script. I don't have push | ||
# access to r-ryantm's repo, so I will just do updates manually | ||
|
||
postFixup = | ||
let | ||
script = writeShellScript "hyprpanel" '' | ||
if [ "$#" -eq 0 ]; then | ||
exec @out@/bin/.hyprpanel | ||
else | ||
exec ${astal.io}/bin/astal -i hyprpanel "$*" | ||
fi | ||
''; | ||
in | ||
# bash | ||
'' | ||
mv "$out/bin/hyprpanel" "$out/bin/.hyprpanel" | ||
cp '${script}' "$out/bin/hyprpanel" | ||
substituteInPlace "$out/bin/hyprpanel" \ | ||
--replace-fail '@out@' "$out" | ||
''; | ||
|
||
meta = { | ||
description = "Bar/Panel for Hyprland with extensive customizability"; | ||
homepage = "https://github.com/Jas-SinghFSU/HyprPanel"; | ||
license = lib.licenses.mit; | ||
maintainers = with lib.maintainers; [ perchun ]; | ||
mainProgram = "hyprpanel"; | ||
platforms = lib.platforms.linux; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,224 @@ | ||
diff --git a/app.ts b/app.ts | ||
index 4457e61..7e75a75 100644 | ||
--- a/app.ts | ||
+++ b/app.ts | ||
@@ -2,7 +2,6 @@ import './src/lib/session'; | ||
import './src/scss/style'; | ||
import './src/globals/useTheme'; | ||
import './src/globals/wallpaper'; | ||
-import './src/globals/systray'; | ||
import './src/globals/dropdown'; | ||
import './src/globals/utilities'; | ||
import './src/components/bar/utils/sideEffects'; | ||
diff --git a/src/components/bar/exports.ts b/src/components/bar/exports.ts | ||
index fc4f9b5..f9254b2 100644 | ||
--- a/src/components/bar/exports.ts | ||
+++ b/src/components/bar/exports.ts | ||
@@ -8,7 +8,6 @@ import { Network } from '../../components/bar/modules/network/index'; | ||
import { Bluetooth } from '../../components/bar/modules/bluetooth/index'; | ||
import { BatteryLabel } from '../../components/bar/modules/battery/index'; | ||
import { Clock } from '../../components/bar/modules/clock/index'; | ||
-import { SysTray } from '../../components/bar/modules/systray/index'; | ||
|
||
// Custom Modules | ||
import { Ram } from '../../components/bar/modules/ram/index'; | ||
@@ -36,7 +35,6 @@ export { | ||
Bluetooth, | ||
BatteryLabel, | ||
Clock, | ||
- SysTray, | ||
|
||
// Custom Modules | ||
Ram, | ||
diff --git a/src/components/bar/index.tsx b/src/components/bar/index.tsx | ||
index e770c04..bd4283b 100644 | ||
--- a/src/components/bar/index.tsx | ||
+++ b/src/components/bar/index.tsx | ||
@@ -9,7 +9,6 @@ import { | ||
Bluetooth, | ||
BatteryLabel, | ||
Clock, | ||
- SysTray, | ||
|
||
// Custom Modules | ||
Ram, | ||
@@ -50,7 +49,6 @@ const widget = { | ||
network: (): JSX.Element => WidgetContainer(Network()), | ||
bluetooth: (): JSX.Element => WidgetContainer(Bluetooth()), | ||
clock: (): JSX.Element => WidgetContainer(Clock()), | ||
- systray: (): JSX.Element => WidgetContainer(SysTray()), | ||
ram: (): JSX.Element => WidgetContainer(Ram()), | ||
cpu: (): JSX.Element => WidgetContainer(Cpu()), | ||
cputemp: (): JSX.Element => WidgetContainer(CpuTemp()), | ||
diff --git a/src/components/bar/modules/systray/index.tsx b/src/components/bar/modules/systray/index.tsx | ||
deleted file mode 100644 | ||
index f25e141..0000000 | ||
--- a/src/components/bar/modules/systray/index.tsx | ||
+++ /dev/null | ||
@@ -1,142 +0,0 @@ | ||
-import { isMiddleClick, isPrimaryClick, isSecondaryClick, Notify } from '../../../../lib/utils'; | ||
-import options from '../../../../options'; | ||
-import AstalTray from 'gi://AstalTray?version=0.1'; | ||
-import { bind, Gio, Variable } from 'astal'; | ||
-import { BarBoxChild } from 'src/lib/types/bar'; | ||
-import { Gdk, Gtk } from 'astal/gtk3'; | ||
- | ||
-const systemtray = AstalTray.get_default(); | ||
-const { ignore, customIcons } = options.bar.systray; | ||
- | ||
-//TODO: Connect to `notify::menu-model` and `notify::action-group` to have up to date menu and action group | ||
-const createMenu = (menuModel: Gio.MenuModel, actionGroup: Gio.ActionGroup | null): Gtk.Menu => { | ||
- const menu = Gtk.Menu.new_from_model(menuModel); | ||
- menu.insert_action_group('dbusmenu', actionGroup); | ||
- | ||
- return menu; | ||
-}; | ||
- | ||
-const MenuCustomIcon = ({ iconLabel, iconColor, item }: MenuCustomIconProps): JSX.Element => { | ||
- return ( | ||
- <label | ||
- className={'systray-icon txt-icon'} | ||
- label={iconLabel} | ||
- css={iconColor ? `color: ${iconColor}` : ''} | ||
- tooltipMarkup={bind(item, 'tooltipMarkup')} | ||
- /> | ||
- ); | ||
-}; | ||
- | ||
-const MenuDefaultIcon = ({ item }: MenuEntryProps): JSX.Element => { | ||
- return <icon className={'systray-icon'} gIcon={bind(item, 'gicon')} tooltipMarkup={bind(item, 'tooltipMarkup')} />; | ||
-}; | ||
- | ||
-const MenuEntry = ({ item, child }: MenuEntryProps): JSX.Element => { | ||
- let menu: Gtk.Menu; | ||
- | ||
- const entryBinding = Variable.derive( | ||
- [bind(item, 'menuModel'), bind(item, 'actionGroup')], | ||
- (menuModel, actionGroup) => { | ||
- if (!menuModel) { | ||
- return console.error(`Menu Model not found for ${item.id}`); | ||
- } | ||
- if (!actionGroup) { | ||
- return console.error(`Action Group not found for ${item.id}`); | ||
- } | ||
- | ||
- menu = createMenu(menuModel, actionGroup); | ||
- }, | ||
- ); | ||
- | ||
- return ( | ||
- <button | ||
- cursor={'pointer'} | ||
- onClick={(self, event) => { | ||
- if (isPrimaryClick(event)) { | ||
- item.activate(0, 0); | ||
- } | ||
- | ||
- if (isSecondaryClick(event)) { | ||
- menu?.popup_at_widget(self, Gdk.Gravity.NORTH, Gdk.Gravity.SOUTH, null); | ||
- } | ||
- | ||
- if (isMiddleClick(event)) { | ||
- Notify({ summary: 'App Name', body: item.id }); | ||
- } | ||
- }} | ||
- onDestroy={() => { | ||
- menu?.destroy(); | ||
- entryBinding.drop(); | ||
- }} | ||
- > | ||
- {child} | ||
- </button> | ||
- ); | ||
-}; | ||
- | ||
-const SysTray = (): BarBoxChild => { | ||
- const isVis = Variable(false); | ||
- | ||
- const componentChildren = Variable.derive( | ||
- [bind(systemtray, 'items'), bind(ignore), bind(customIcons)], | ||
- (items, ignored, custIcons) => { | ||
- const filteredTray = items.filter(({ id }) => !ignored.includes(id) && id !== null); | ||
- | ||
- isVis.set(filteredTray.length > 0); | ||
- | ||
- return filteredTray.map((item) => { | ||
- const matchedCustomIcon = Object.keys(custIcons).find((iconRegex) => item.id.match(iconRegex)); | ||
- | ||
- if (matchedCustomIcon !== undefined) { | ||
- const iconLabel = custIcons[matchedCustomIcon].icon || ''; | ||
- const iconColor = custIcons[matchedCustomIcon].color; | ||
- | ||
- return ( | ||
- <MenuEntry item={item}> | ||
- <MenuCustomIcon iconLabel={iconLabel} iconColor={iconColor} item={item} /> | ||
- </MenuEntry> | ||
- ); | ||
- } | ||
- return ( | ||
- <MenuEntry item={item}> | ||
- <MenuDefaultIcon item={item} /> | ||
- </MenuEntry> | ||
- ); | ||
- }); | ||
- }, | ||
- ); | ||
- | ||
- const component = ( | ||
- <box | ||
- className={'systray-container'} | ||
- onDestroy={() => { | ||
- isVis.drop(); | ||
- componentChildren.drop(); | ||
- }} | ||
- > | ||
- {componentChildren()} | ||
- </box> | ||
- ); | ||
- | ||
- return { | ||
- component, | ||
- isVisible: true, | ||
- boxClass: 'systray', | ||
- isVis, | ||
- isBox: true, | ||
- props: {}, | ||
- }; | ||
-}; | ||
- | ||
-interface MenuCustomIconProps { | ||
- iconLabel: string; | ||
- iconColor: string; | ||
- item: AstalTray.TrayItem; | ||
-} | ||
- | ||
-interface MenuEntryProps { | ||
- item: AstalTray.TrayItem; | ||
- child?: JSX.Element; | ||
-} | ||
- | ||
-export { SysTray }; | ||
diff --git a/src/globals/systray.ts b/src/globals/systray.ts | ||
deleted file mode 100644 | ||
index c9dbe43..0000000 | ||
--- a/src/globals/systray.ts | ||
+++ /dev/null | ||
@@ -1,18 +0,0 @@ | ||
-import AstalTray from 'gi://AstalTray'; | ||
-import { errorHandler } from 'src/lib/utils'; | ||
-const systemtray = AstalTray.get_default(); | ||
- | ||
-globalThis.getSystrayItems = (): string => { | ||
- try { | ||
- const items = systemtray | ||
- .get_items() | ||
- .map((systrayItem) => systrayItem.id) | ||
- .join('\n'); | ||
- | ||
- return items; | ||
- } catch (error) { | ||
- errorHandler(error); | ||
- } | ||
-}; | ||
- | ||
-export { getSystrayItems }; |