summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorQuentin Aristote <quentin@aristote.fr>2021-09-20 21:37:34 +0200
committerQuentin Aristote <quentin@aristote.fr>2021-09-20 21:37:34 +0200
commitd4c0f93e1d61960e6bd534ad29fc84a1190a8ff4 (patch)
tree814a404de46751336494aaf0f3c23b1f260234e4
parent6469af670d055c8f4a72a6e03a19d34f931ef177 (diff)
use lib.optional* functions
-rw-r--r--home/config/i3/keybindings.nix23
-rw-r--r--home/config/i3/startup.nix40
-rw-r--r--home/pkgs/lockscreen/default.nix55
3 files changed, 45 insertions, 73 deletions
diff --git a/home/config/i3/keybindings.nix b/home/config/i3/keybindings.nix
index b35dc8a..5efdeaa 100644
--- a/home/config/i3/keybindings.nix
+++ b/home/config/i3/keybindings.nix
@@ -34,20 +34,15 @@ in {
$(( $(${brightnessctlKbd} max) - $(${brightnessctlKbd} get) ))
'';
"Print" = "exec xfce4-screenshooter";
- } // (if backgroundImage != null then {
+ } // (lib.optionalAttrs (backgroundImage != null) {
"${modifier}+l" = "exec ${lockscreen}/bin/lockscreen.sh";
- } else
- { }) // (if config.programs.alacritty.enable then {
- "${modifier}+Return" = "exec ${pkgs.alacritty}/bin/alacritty";
- } else
- { }) // (if config.programs.rofi.enable then {
- "${modifier}+d" = ''exec "${rofi} -modi drun,run,window -show drun"'';
- "${modifier}+Shift+d" = "exec ${rofi} -show window";
- } else
- { }) // (if config.services.emacs.client.enable then {
- "${modifier}+Control+r" =
- "exec systemctl --user restart emacs.service";
- } else
- { }));
+ }) // (lib.optionalAttrs config.programs.alacritty.enable {
+ "${modifier}+Return" = "exec ${pkgs.alacritty}/bin/alacritty";
+ }) // (lib.optionalAttrs config.programs.rofi.enable {
+ "${modifier}+d" = ''exec "${rofi} -modi drun,run,window -show drun"'';
+ "${modifier}+Shift+d" = "exec ${rofi} -show window";
+ }) // (lib.optionalAttrs config.services.emacs.client.enable {
+ "${modifier}+Control+r" = "exec systemctl --user restart emacs.service";
+ }));
};
}
diff --git a/home/config/i3/startup.nix b/home/config/i3/startup.nix
index 3c7cdf3..cdad53c 100644
--- a/home/config/i3/startup.nix
+++ b/home/config/i3/startup.nix
@@ -6,31 +6,17 @@ in {
autostart = { command, always ? false, notification ? false }: {
inherit command always notification;
};
- in (if (config.services.redshift.enable) then
- [ (autostart { command = "systemctl --user start redshift"; }) ]
- else
- [ ]) ++ (if background-image != null then
- [
- (autostart {
- command = "${pkgs.feh}/bin/feh --bg-scale ${background-image}";
- })
- ]
- else
- [ ]) ++ (if config.services.screen-locker.enable then
- [
- (autostart {
- command =
- "systemctl --user xidlehook.service";
- })
- ]
- else
- [ ]) ++ (if config.services.emacs.enable then
- [ (autostart { command = "systemctl --user start emacs.service"; }) ]
- else
- [ ]) ++ [
- # Launch frequently used apps
- (autostart { command = "thunderbird"; })
- (autostart { command = "signal-desktop"; })
- (autostart { command = ''i3-msg "workspace 10; exec keepassxc"''; })
- ];
+ in (lib.optional config.services.redshift.enable
+ (autostart { command = "systemctl --user start redshift"; }))
+++ (lib.optional (background-image != null) (autostart {
+ command = "${pkgs.feh}/bin/feh --bg-scale ${background-image}";
+ })) ++ (lib.optional config.services.xidlehook.enable
+ (autostart { command = "systemctl --user xidlehook.service"; }))
+ ++ (lib.optional config.services.emacs.enable
+ (autostart { command = "systemctl --user start emacs.service"; })) ++ [
+ # Launch frequently used apps
+ (autostart { command = "thunderbird"; })
+ (autostart { command = "signal-desktop"; })
+ (autostart { command = ''i3-msg "workspace 10; exec keepassxc"''; })
+ ];
}
diff --git a/home/pkgs/lockscreen/default.nix b/home/pkgs/lockscreen/default.nix
index b36b08b..4da4743 100644
--- a/home/pkgs/lockscreen/default.nix
+++ b/home/pkgs/lockscreen/default.nix
@@ -1,37 +1,28 @@
{ pkgs, backgroundImage ? null, resolution ? "1920x1080" }:
let useBackgroundImage = backgroundImage != null;
-in pkgs.runCommand "lockscreen" {
- buildInputs = with pkgs;
- [
- # xorg.xdpyinfo
- ];
- envVariable = true;
-} (''
+in pkgs.runCommand "lockscreen" { envVariable = true; } (''
mkdir -p $out/{bin,share}
-'' + (if useBackgroundImage then ''
+'' + (lib.optionalString useBackgroundImage ''
${pkgs.imagemagick}/bin/convert ${backgroundImage} -resize ${resolution} -blur 0x5 RGB:$out/share/lockscreen.png
-'' else
- "") + ''
- echo > $out/bin/lockscreen.sh \
- "export PATH=$PATH
- ${pkgs.i3lock-color}/bin/i3lock-color \\
- '' + (if useBackgroundImage then ''
- --raw ${resolution}:rgb \\
- --image $out/share/lockscreen.png \\
- '' else
- "") + ''
- --no-unlock-indicator \\
- --composite \\
- --clock \\
- --ignore-empty-password \\
- --time-color=FFFFFFFF \\
- --date-color=00000000 \\
- --time-size=100"
- '' + (if useBackgroundImage then ''
- chmod 444 $out/share/lockscreen.png
- '' else
- "") + ''
- chmod 555 $out/bin/lockscreen.sh
- chmod 555 $out/{bin,share}
- '')
+'') + ''
+ echo > $out/bin/lockscreen.sh \
+ "export PATH=$PATH
+ ${pkgs.i3lock-color}/bin/i3lock-color \\
+ '' + (lib.optionalString useBackgroundImage ''
+ --raw ${resolution}:rgb \\
+ --image $out/share/lockscreen.png \\
+ '') + ''
+ --no-unlock-indicator \\
+ --composite \\
+ --clock \\
+ --ignore-empty-password \\
+ --time-color=FFFFFFFF \\
+ --date-color=00000000 \\
+ --time-size=100"
+ '' + (lib.optionalString useBackgroundImage ''
+ chmod 444 $out/share/lockscreen.png
+ '') + ''
+ chmod 555 $out/bin/lockscreen.sh
+ chmod 555 $out/{bin,share}
+ '')