Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions modules/lib/maintainers.nix
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,12 @@
github = "bamhm182";
githubId = 920269;
};
bbigras = {
name = "bbigras";
email = "24027+bbigras@users.noreply.github.com";
github = "bbigras";
githubId = 24027;
};
bikku = {
name = "Bikku";
email = "bikku+dev@slmail.me";
Expand Down
145 changes: 145 additions & 0 deletions modules/programs/wayland-bongocat.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
{
config,
lib,
pkgs,
...
}:
let
inherit (lib)
mkIf
mkOption
types
;
cfg = config.programs.wayland-bongocat;
boolToInt = value: if value then 1 else 0;
in
{
meta.maintainers = [ lib.maintainers.bbigras ];
options.programs.wayland-bongocat = {
enable = lib.mkEnableOption "the wayland bongocat overlay";
package = lib.mkPackageOption pkgs "wayland-bongocat" { nullable = true; };

cat = {
height = mkOption {
default = 50;
example = 25;
type = types.ints.unsigned;
description = "Size of bongo cat (16-128).";
};
xOffset = mkOption {
default = 0;
example = 25;
type = types.ints.unsigned;
description = "Horizontal position offset.";
};
yOffset = mkOption {
default = 0;
example = 25;
type = types.ints.unsigned;
description = "Vertical position offset.";
};
};
keyboardDevices = mkOption {
default = [ "/dev/input/event4" ];
example = [ "/dev/input/event1" ];
type = types.listOf types.path;
description = "Input device paths.";
};
fps = mkOption {
default = 60;
example = 60;
type = types.ints.unsigned;
description = "Animation frame rate (1-120).";
};
overlayOpacity = mkOption {
default = 150;
example = 0;
type = types.ints.unsigned;
description = "Background opacity (0-255, 0=transparent).";
};
overlayPosition = mkOption {
default = "top";
example = "bottom";
type = types.enum [
"bottom"
"top"
];
description = "Position of overlay on screen";
};
debug = mkOption {
type = types.bool;
default = false;
description = "Enable debug logging";
};
monitor = mkOption {
default = null;
example = "eDP-1";
type = types.str;
description = ''
Monitor to display on (e.g., "eDP-1", "HDMI-A-1")
Default (null) = Auto-detect
'';
};
};
config =
let
configDir =
if (pkgs.stdenv.targetPlatform.isDarwin) then
"Library/Application Support/wayland-bongocat"
else
"${config.xdg.configHome}/wayland-bongocat";
configFile = "${configDir}/settings.conf";

settings = {
main = {
cat_height = cfg.cat.height;
cat_x_offset = cfg.cat.xOffset;
cat_y_offset = cfg.cat.yOffset;
enable_debug = boolToInt cfg.debug;
fps = cfg.fps;
overlay_opacity = cfg.overlayOpacity;
};
};
in
mkIf cfg.enable {
home = {
packages = mkIf (cfg.package != null) [ cfg.package ];

file.wayland-bongocat-settings = {
enable = settings != { };
target = configFile;
text =
let
toIni = lib.generators.toINI { };
in
lib.mkMerge (
[
"# Generated by Home Manager."
(toIni settings)
]
++ (builtins.map (item: "keyboard_device=${item}") cfg.keyboardDevices)
);

};
};
systemd.user.services = {
bongocat = {
Unit = {
After = [ "graphical-session.target" ];
PartOf = [ "graphical-session.target" ];
};
Install = {
WantedBy = [ "graphical-session.target" ];
};
Service = {
Restart = "on-failure";
PrivateTmp = true;
ProtectSystem = "full";
Type = "exec";
Slice = "session.slice"; # ?
ExecStart = "${pkgs.wayland-bongocat}/bin/bongocat --config ${configFile}";
};
};
};
};
}
41 changes: 41 additions & 0 deletions tests/modules/programs/wayland-bongocat/custom-settings.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{ config, pkgs, ... }:
{
config = {
programs.wayland-bongocat = {
package = config.lib.test.mkStubPackage { name = "wayland-bongocat"; };
enable = true;
cat = {
height = 123;
};
keyboardDevices = [
"/dev/input/event1"
"/dev/input/event2"
];
};

nmt.script =
let
configDir =
if pkgs.stdenv.isDarwin then
"home-files/Library/Application Support/wayland-bongocat"
else
"home-files/.config/wayland-bongocat";
configFile = "${configDir}/settings.conf";
in
''
assertFileExists "${configFile}"
assertFileContent "${configFile}" ${pkgs.writeText "wayland-bongocat.config-custom.expected" ''
# Generated by Home Manager.
[main]
cat_height=123
cat_x_offset=0
cat_y_offset=0
enable_debug=0
fps=60
overlay_opacity=150

keyboard_device=/dev/input/event1
keyboard_device=/dev/input/event2''}
Comment on lines +35 to +38
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not done yet, but if somebody sees this, I'm not happy with the empty line and the missing newline at the end.

'';
};
}
21 changes: 21 additions & 0 deletions tests/modules/programs/wayland-bongocat/default-settings.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{ config, pkgs, ... }:
{
config = {
programs.wayland-bongocat = {
package = config.lib.test.mkStubPackage { name = "wayland-bongocat"; };
enable = true;
};

nmt.script =
let
configDir =
if pkgs.stdenv.isDarwin then
"home-files/Library/Application Support/wayland-bongocat"
else
"home-files/.config/wayland-bongocat";
in
''
assertPathNotExists "${configDir}/settings.conf"
'';
};
}
4 changes: 4 additions & 0 deletions tests/modules/programs/wayland-bongocat/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
wayland-bongocat-default-settings = ./default-settings.nix;
wayland-bongocat-custom-settings = ./custom-settings.nix;
}
Loading