mirror of
https://github.com/nix-community/home-manager.git
synced 2025-11-08 19:46:05 +01:00
(cherry picked from commit f5098b0740)
Co-authored-by: Perchun Pak <git@perchun.it>
This commit is contained in:
parent
7aae0ee71a
commit
d457fa3c76
8 changed files with 265 additions and 0 deletions
|
|
@ -137,6 +137,7 @@ let
|
|||
./programs/htop.nix
|
||||
./programs/hyfetch.nix
|
||||
./programs/hyprlock.nix
|
||||
./programs/hyprpanel.nix
|
||||
./programs/i3bar-river.nix
|
||||
./programs/i3blocks.nix
|
||||
./programs/i3status-rust.nix
|
||||
|
|
|
|||
121
modules/programs/hyprpanel.nix
Normal file
121
modules/programs/hyprpanel.nix
Normal file
|
|
@ -0,0 +1,121 @@
|
|||
{
|
||||
pkgs,
|
||||
lib,
|
||||
config,
|
||||
...
|
||||
}:
|
||||
let
|
||||
cfg = config.programs.hyprpanel;
|
||||
jsonFormat = pkgs.formats.json { };
|
||||
in
|
||||
{
|
||||
meta.maintainers = [ lib.maintainers.perchun ];
|
||||
|
||||
options.programs.hyprpanel = {
|
||||
enable = lib.mkEnableOption "HyprPanel";
|
||||
|
||||
package = lib.mkPackageOption pkgs "hyprpanel" { };
|
||||
|
||||
settings = lib.mkOption {
|
||||
type = jsonFormat.type;
|
||||
default = { };
|
||||
example = lib.literalExpression ''
|
||||
bar.battery.label = true;
|
||||
bar.bluetooth.label = false;
|
||||
bar.clock.format = "%H:%M:%S";
|
||||
bar.layouts = {
|
||||
"*" = {
|
||||
left = [
|
||||
"dashboard"
|
||||
"workspaces"
|
||||
"media"
|
||||
];
|
||||
middle = [ "windowtitle" ];
|
||||
right = [
|
||||
"volume"
|
||||
"network"
|
||||
"bluetooth"
|
||||
"notifications"
|
||||
];
|
||||
};
|
||||
};
|
||||
'';
|
||||
description = ''
|
||||
Configuration written to
|
||||
{file}`$XDG_CONFIG_HOME/hyprpanel/config.json`.
|
||||
|
||||
See <https://hyprpanel.com/configuration/settings.html#home-manager-module>
|
||||
for the full list of options.
|
||||
'';
|
||||
};
|
||||
|
||||
systemd.enable = lib.mkEnableOption "HyprPanel systemd integration" // {
|
||||
default = true;
|
||||
};
|
||||
|
||||
dontAssertNotificationDaemons = lib.mkOption {
|
||||
default = true;
|
||||
example = false;
|
||||
description = ''
|
||||
Whether to check for other notification daemons.
|
||||
|
||||
You might want to set this to false, because hyprpanel's notification
|
||||
daemon is buggy and you may prefer something else.
|
||||
'';
|
||||
type = lib.types.bool;
|
||||
};
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
assertions = [
|
||||
{
|
||||
assertion = cfg.dontAssertNotificationDaemons && !config.services.swaync.enable;
|
||||
message = ''
|
||||
Only one notification daemon can be enabled at once. You have enabled
|
||||
swaync and hyprpanel at once.
|
||||
|
||||
If you dont want to use hyprpanel's notification daemon, set
|
||||
`programs.hyprpanel.dontAssertNotificationDaemons` to true.
|
||||
'';
|
||||
}
|
||||
];
|
||||
|
||||
home.packages = [ cfg.package ];
|
||||
|
||||
programs.hyprpanel.settings = lib.mkIf config.services.hypridle.enable {
|
||||
# fix hypridle module if user uses systemd service
|
||||
bar.customModules.hypridle.startCommand = lib.mkDefault "systemctl --user start hypridle.service";
|
||||
bar.customModules.hypridle.stopCommand = lib.mkDefault "systemctl --user stop hypridle.service";
|
||||
bar.customModules.hypridle.isActiveCommand = lib.mkDefault "systemctl --user status hypridle.service | grep -q 'Active: active (running)' && echo 'yes' || echo 'no'";
|
||||
};
|
||||
|
||||
xdg.configFile.hyprpanel = lib.mkIf (cfg.settings != { }) {
|
||||
target = "hyprpanel/config.json";
|
||||
source = jsonFormat.generate "hyprpanel-config" cfg.settings;
|
||||
# hyprpanel replaces it with the same file, but without new line in the end
|
||||
force = true;
|
||||
};
|
||||
|
||||
systemd.user.services.hyprpanel = lib.mkIf cfg.systemd.enable {
|
||||
Unit = {
|
||||
Description = "Bar/Panel for Hyprland with extensive customizability";
|
||||
Documentation = "https://hyprpanel.com/getting_started/hyprpanel.html";
|
||||
PartOf = [ config.wayland.systemd.target ];
|
||||
After = [ config.wayland.systemd.target ];
|
||||
ConditionEnvironment = "WAYLAND_DISPLAY";
|
||||
X-Restart-Triggers = lib.optional (cfg.settings != { }) "${config.xdg.configFile.hyprpanel.source}";
|
||||
};
|
||||
|
||||
Service = {
|
||||
ExecStart = "${cfg.package}/bin/hyprpanel";
|
||||
ExecReload = "${pkgs.coreutils}/bin/kill -SIGUSR2 $MAINPID";
|
||||
Restart = "on-failure";
|
||||
KillMode = "mixed";
|
||||
};
|
||||
|
||||
Install = {
|
||||
WantedBy = [ config.wayland.systemd.target ];
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
@ -377,6 +377,7 @@ import nmtSrc {
|
|||
./modules/programs/halloy
|
||||
./modules/programs/hexchat
|
||||
./modules/programs/hyprlock
|
||||
./modules/programs/hyprpanel
|
||||
./modules/programs/i3bar-river
|
||||
./modules/programs/i3blocks
|
||||
./modules/programs/i3status-rust
|
||||
|
|
|
|||
31
tests/modules/programs/hyprpanel/basic-config.json
Normal file
31
tests/modules/programs/hyprpanel/basic-config.json
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
{
|
||||
"bar": {
|
||||
"battery": {
|
||||
"label": true
|
||||
},
|
||||
"bluetooth": {
|
||||
"label": false
|
||||
},
|
||||
"clock": {
|
||||
"format": "%H:%M:%S"
|
||||
},
|
||||
"layouts": {
|
||||
"*": {
|
||||
"left": [
|
||||
"dashboard",
|
||||
"workspaces",
|
||||
"media"
|
||||
],
|
||||
"middle": [
|
||||
"windowtitle"
|
||||
],
|
||||
"right": [
|
||||
"volume",
|
||||
"network",
|
||||
"bluetooth",
|
||||
"notifications"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
34
tests/modules/programs/hyprpanel/basic-config.nix
Normal file
34
tests/modules/programs/hyprpanel/basic-config.nix
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
{ config, ... }:
|
||||
{
|
||||
programs.hyprpanel = {
|
||||
enable = true;
|
||||
package = config.lib.test.mkStubPackage { name = "hyprpanel"; };
|
||||
settings = {
|
||||
bar.battery.label = true;
|
||||
bar.bluetooth.label = false;
|
||||
bar.clock.format = "%H:%M:%S";
|
||||
bar.layouts = {
|
||||
"*" = {
|
||||
left = [
|
||||
"dashboard"
|
||||
"workspaces"
|
||||
"media"
|
||||
];
|
||||
middle = [ "windowtitle" ];
|
||||
right = [
|
||||
"volume"
|
||||
"network"
|
||||
"bluetooth"
|
||||
"notifications"
|
||||
];
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
nmt.script = ''
|
||||
assertFileContent \
|
||||
"home-files/.config/hyprpanel/config.json" \
|
||||
${./basic-config.json}
|
||||
'';
|
||||
}
|
||||
4
tests/modules/programs/hyprpanel/default.nix
Normal file
4
tests/modules/programs/hyprpanel/default.nix
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
hyprpanel-basic-config = ./basic-config.nix;
|
||||
hyprpanel-with-hypridle = ./with-hypridle.nix;
|
||||
}
|
||||
38
tests/modules/programs/hyprpanel/with-hypridle.json
Normal file
38
tests/modules/programs/hyprpanel/with-hypridle.json
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
{
|
||||
"bar": {
|
||||
"battery": {
|
||||
"label": true
|
||||
},
|
||||
"bluetooth": {
|
||||
"label": false
|
||||
},
|
||||
"clock": {
|
||||
"format": "%H:%M:%S"
|
||||
},
|
||||
"customModules": {
|
||||
"hypridle": {
|
||||
"isActiveCommand": "systemctl --user status hypridle.service | grep -q 'Active: active (running)' && echo 'yes' || echo 'no'",
|
||||
"startCommand": "systemctl --user start hypridle.service",
|
||||
"stopCommand": "systemctl --user stop hypridle.service"
|
||||
}
|
||||
},
|
||||
"layouts": {
|
||||
"*": {
|
||||
"left": [
|
||||
"dashboard",
|
||||
"workspaces",
|
||||
"media"
|
||||
],
|
||||
"middle": [
|
||||
"windowtitle"
|
||||
],
|
||||
"right": [
|
||||
"volume",
|
||||
"network",
|
||||
"bluetooth",
|
||||
"notifications"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
35
tests/modules/programs/hyprpanel/with-hypridle.nix
Normal file
35
tests/modules/programs/hyprpanel/with-hypridle.nix
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
{ config, ... }:
|
||||
{
|
||||
services.hypridle.enable = true;
|
||||
programs.hyprpanel = {
|
||||
enable = true;
|
||||
package = config.lib.test.mkStubPackage { name = "hyprpanel"; };
|
||||
settings = {
|
||||
bar.battery.label = true;
|
||||
bar.bluetooth.label = false;
|
||||
bar.clock.format = "%H:%M:%S";
|
||||
bar.layouts = {
|
||||
"*" = {
|
||||
left = [
|
||||
"dashboard"
|
||||
"workspaces"
|
||||
"media"
|
||||
];
|
||||
middle = [ "windowtitle" ];
|
||||
right = [
|
||||
"volume"
|
||||
"network"
|
||||
"bluetooth"
|
||||
"notifications"
|
||||
];
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
nmt.script = ''
|
||||
assertFileContent \
|
||||
"home-files/.config/hyprpanel/config.json" \
|
||||
${./with-hypridle.json}
|
||||
'';
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue