1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-12-20 08:49:47 +01:00

wob: add module

Signed-off-by: Sefa Eyeoglu <contact@scrumplex.net>
This commit is contained in:
Sefa Eyeoglu 2024-01-28 10:46:09 +01:00 committed by GitHub
parent 7a461c70ed
commit ebba24a6fe
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 143 additions and 0 deletions

View file

@ -1392,6 +1392,15 @@ in {
This module replaces 'programs.rtx', which has been removed.
'';
}
{
time = "2024-01-27T22:53:00+00:00";
condition = hostPlatform.isLinux;
message = ''
A new module is available: 'services.wob'.
'';
}
];
};
}

View file

@ -364,6 +364,7 @@ let
./services/window-managers/spectrwm.nix
./services/window-managers/xmonad.nix
./services/wlsunset.nix
./services/wob.nix
./services/xcape.nix
./services/xembed-sni-proxy.nix
./services/xidlehook.nix

79
modules/services/wob.nix Normal file
View file

@ -0,0 +1,79 @@
{ config, lib, pkgs, ... }:
let
inherit (lib)
getExe literalExpression mkEnableOption mkIf mkOption mkPackageOption
optional;
cfg = config.services.wob;
settingsFormat = pkgs.formats.ini { };
configFile = settingsFormat.generate "wob.ini" cfg.settings;
in {
meta.maintainers = with lib.maintainers; [ Scrumplex ];
options.services.wob = {
enable = mkEnableOption "wob";
package = mkPackageOption pkgs "wob" { };
settings = mkOption {
type = settingsFormat.type;
default = { };
example = literalExpression ''
{
"" = {
border_size = 10;
height = 50;
};
"output.foo".name = "DP-1";
"style.muted".background_color = "032cfc";
}
'';
description = ''
Configuration written to {file}`$XDG_CONFIG_HOME/wob/wob.ini`.
See {manpage}`wob.ini(5)` for documentation.
'';
};
systemd = mkEnableOption "systemd service and socket for wob"
// mkOption { default = true; };
};
config = mkIf cfg.enable {
assertions = [
(lib.hm.assertions.assertPlatform "services.wob" pkgs lib.platforms.linux)
];
systemd.user = mkIf cfg.systemd {
services.wob = {
Unit = {
Description =
"A lightweight overlay volume/backlight/progress/anything bar for Wayland";
Documentation = "man:wob(1)";
PartOf = "graphical-session.target";
After = "graphical-session.target";
ConditionEnvironment = "WAYLAND_DISPLAY";
};
Service = {
StandardInput = "socket";
ExecStart = builtins.concatStringsSep " " ([ (getExe cfg.package) ]
++ optional (cfg.settings != { }) "--config ${configFile}");
};
Install.WantedBy = [ "graphical-session.target" ];
};
sockets.wob = {
Socket = {
ListenFIFO = "%t/wob.sock";
SocketMode = "0600";
RemoveOnStop = "yes";
FlushPending = "yes";
};
Install.WantedBy = [ "sockets.target" ];
};
};
xdg.configFile."wob/wob.ini" =
mkIf (cfg.settings != { }) { source = configFile; };
};
}

View file

@ -261,6 +261,7 @@ in import nmtSrc {
./modules/services/window-managers/spectrwm
./modules/services/window-managers/sway
./modules/services/wlsunset
./modules/services/wob
./modules/services/xsettingsd
./modules/systemd
./modules/targets-linux

View file

@ -0,0 +1 @@
{ wob-service = ./wob-service.nix; }

View file

@ -0,0 +1,2 @@
[]
background_color=ddddddff

View file

@ -0,0 +1,13 @@
[Install]
WantedBy=graphical-session.target
[Service]
ExecStart=@wob@/bin/wob --config /nix/store/00000000000000000000000000000000-wob.ini
StandardInput=socket
[Unit]
After=graphical-session.target
ConditionEnvironment=WAYLAND_DISPLAY
Description=A lightweight overlay volume/backlight/progress/anything bar for Wayland
Documentation=man:wob(1)
PartOf=graphical-session.target

View file

@ -0,0 +1,8 @@
[Install]
WantedBy=sockets.target
[Socket]
FlushPending=yes
ListenFIFO=%t/wob.sock
RemoveOnStop=yes
SocketMode=0600

View file

@ -0,0 +1,29 @@
{ config, ... }:
{
services.wob = {
enable = true;
package = config.lib.test.mkStubPackage {
name = "wob";
outPath = "@wob@";
};
systemd = true;
settings."".background_color = "ddddddff";
};
nmt.script = ''
serviceFile=home-files/.config/systemd/user/wob.service
socketFile=home-files/.config/systemd/user/wob.socket
configFile=home-files/.config/wob/wob.ini
assertFileExists $serviceFile
assertFileExists $socketFile
assertFileExists $configFile
assertFileContent $(normalizeStorePaths $serviceFile) ${
./wob-service-expected.service
}
assertFileContent $socketFile ${./wob-service-expected.socket}
assertFileContent $configFile ${./wob-service-expected.ini}
'';
}