Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

devilspie2: add module #1477

Merged
merged 7 commits into from
Jul 5, 2021
Merged
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
3 changes: 3 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,9 @@

/modules/services/clipmenu.nix @DamienCassou

/modules/services/devilspie2.nix @dawidsowa
dawidsowa marked this conversation as resolved.
Show resolved Hide resolved
/tests/modules/services/devilspie2 @dawidsowa

/modules/services/dropbox.nix @eyJhb
/tests/modules/services/dropbox @eyJhb

Expand Down
1 change: 1 addition & 0 deletions modules/modules.nix
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ let
(loadModule ./services/cbatticon.nix { condition = hostPlatform.isLinux; })
(loadModule ./services/clipmenu.nix { condition = hostPlatform.isLinux; })
(loadModule ./services/compton.nix { })
(loadModule ./services/devilspie2.nix { condition = hostPlatform.isLinux; })
(loadModule ./services/dropbox.nix { condition = hostPlatform.isLinux; })
(loadModule ./services/dunst.nix { })
(loadModule ./services/dwm-status.nix { condition = hostPlatform.isLinux; })
Expand Down
42 changes: 42 additions & 0 deletions modules/services/devilspie2.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{ config, lib, pkgs, ... }:

with lib;
let cfg = config.services.devilspie2;
in {
meta.maintainers = [ maintainers.dawidsowa ];

options = {
services.devilspie2 = {
enable = mkEnableOption ''
Devilspie2, a window matching utility, allowing the user to
perform scripted actions on windows as they are created'';

config = mkOption {
type = types.lines;
default = "";
description = ''
Content of file placed in the devilspie2 config directory.
'';
example = ''
if (get_window_class() == "Gnome-terminal") then
make_always_on_top();
end
'';
};
};
};

config = mkIf cfg.enable {
systemd.user.services.devilspie2 = {
Service.ExecStart = "${pkgs.devilspie2}/bin/devilspie2";
Unit = {
Description = "devilspie2";
After = [ "graphical-session-pre.target" ];
PartOf = [ "graphical-session.target" ];
};
Install.WantedBy = [ "graphical-session.target" ];
};

xdg.configFile."devilspie2/config.lua".text = cfg.config;
};
}
1 change: 1 addition & 0 deletions tests/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ import nmt {
./modules/programs/waybar
./modules/programs/xmobar
./modules/services/barrier
./modules/services/devilspie2
./modules/services/dropbox
./modules/services/emacs
./modules/services/fluidsynth
Expand Down
11 changes: 11 additions & 0 deletions tests/modules/services/devilspie2/config.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
if (get_window_class() == "Gnome-terminal") then
make_always_on_top();
end

if string.match(get_window_name(), "LibreOffice Writer") then
maximize();
end

if (get_window_class()=="Org.gnome.Nautilus") then
set_window_geometry(1600,300,900,700);
end
39 changes: 39 additions & 0 deletions tests/modules/services/devilspie2/configuration.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{ config, pkgs, ... }: {
config = {
services.devilspie2 = {
enable = true;

config = ''
if (get_window_class() == "Gnome-terminal") then
make_always_on_top();
end

if string.match(get_window_name(), "LibreOffice Writer") then
maximize();
end

if (get_window_class()=="Org.gnome.Nautilus") then
set_window_geometry(1600,300,900,700);
end
'';
};

nixpkgs.overlays = [
(self: super: { devilspie2 = pkgs.writeScriptBin "dummy-devilspie2" ""; })
];

nmt.script = ''
configlua=home-files/.config/devilspie2/config.lua

assertFileExists $configlua

assertFileContent $configlua ${./config.lua}

serviceFile=home-files/.config/systemd/user/devilspie2.service

assertFileExists $serviceFile

assertFileRegex $serviceFile 'ExecStart=.*/bin/devilspie2'
'';
};
}
1 change: 1 addition & 0 deletions tests/modules/services/devilspie2/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{ devilspie2-configuration = ./configuration.nix; }