1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-11-26 21:19:45 +01:00

flameshot: add settings option

This commit is contained in:
Robert Helgesson 2021-10-11 21:41:49 +02:00
parent 32285d8fe6
commit 0b47ded208
No known key found for this signature in database
GPG key ID: 36BDAA14C2797E89
5 changed files with 77 additions and 1 deletions

View file

@ -5,12 +5,35 @@ with lib;
let
cfg = config.services.flameshot;
package = pkgs.flameshot;
iniFormat = pkgs.formats.ini { };
iniFile = iniFormat.generate "flameshot.ini" cfg.settings;
in {
meta.maintainers = [ maintainers.hamhut1066 ];
options = { services.flameshot = { enable = mkEnableOption "Flameshot"; }; };
options.services.flameshot = {
enable = mkEnableOption "Flameshot";
settings = mkOption {
type = iniFormat.type;
default = { };
example = {
General = {
disabledTrayIcon = true;
showStartupLaunchMessage = false;
};
};
description = ''
Configuration to use for Flameshot. See
<link xlink:href="https://github.com/flameshot-org/flameshot/blob/master/flameshot.example.ini"/>
for available options.
'';
};
};
config = mkIf cfg.enable {
assertions = [
@ -20,12 +43,17 @@ in {
home.packages = [ package ];
xdg.configFile = mkIf (cfg.settings != { }) {
"flameshot/flameshot.ini".source = iniFile;
};
systemd.user.services.flameshot = {
Unit = {
Description = "Flameshot screenshot tool";
Requires = [ "tray.target" ];
After = [ "graphical-session-pre.target" "tray.target" ];
PartOf = [ "graphical-session.target" ];
X-Restart-Triggers = mkIf (cfg.settings != { }) [ "${iniFile}" ];
};
Install = { WantedBy = [ "graphical-session.target" ]; };

View file

@ -124,6 +124,7 @@ import nmt {
./modules/services/devilspie2
./modules/services/dropbox
./modules/services/emacs
./modules/services/flameshot
./modules/services/fluidsynth
./modules/services/fnott
./modules/services/git-sync

View file

@ -0,0 +1,4 @@
{
flameshot-empty-settings = ./empty-settings.nix;
flameshot-example-settings = ./example-settings.nix;
}

View file

@ -0,0 +1,13 @@
{ ... }:
{
config = {
services.flameshot = { enable = true; };
test.stubs.flameshot = { };
nmt.script = ''
assertPathNotExists home-files/.config/flameshot/flameshot.ini
'';
};
}

View file

@ -0,0 +1,30 @@
{ ... }:
{
config = {
services.flameshot = {
enable = true;
settings = {
General = {
disabledTrayIcon = true;
showStartupLaunchMessage = false;
};
};
};
test.stubs.flameshot = { };
nmt.script = ''
assertFileContent \
home-files/.config/flameshot/flameshot.ini \
${
builtins.toFile "expected.ini" ''
[General]
disabledTrayIcon=true
showStartupLaunchMessage=false
''
}
'';
};
}