swaybg systemd service

This commit is contained in:
Tristan 2023-05-11 11:55:57 +01:00
parent 3ffd1c7822
commit a5f9c29669
6 changed files with 64 additions and 10 deletions

View file

@ -8,14 +8,32 @@ let
+ concatStringsSep "\n" (map displayHyprlandSetting displays);
displayHyprlandSetting = display:
"monitor = " + display.name +
"monitor = " + specificDisplay display +
", " + resToString display.resolution +
", " + display.position +
", " + toString display.scaling +
(if ( display.wallpaper != "" ) then ''
", " + toString display.scaling;
exec-once = ${pkgs.swaybg}/bin/swaybg -o ${display.name} -i ${display.wallpaper} &
'' else "");
swaybgJob = displays:
{
Unit = {
Description = "SwayBG";
};
Service = {
ExecStart = "${pkgs.swaybg}/bin/swaybg " +
concatStringsSep " " (map swaybgCmd displays);
};
Install = {
WantedBy = ["graphical-session.target"];
};
};
swaybgCmd = display:
if (display.wallpaper != "") then "-o ${display.name} -i ${display.wallpaper}" else "";
specificDisplay = display:
if display.description == ""
then display.name
else "desc:" + display.description;
resolutionType = types.submodule ({ x, y, freq, ... }:
{
@ -43,6 +61,10 @@ let
name = mkOption {
description = "name of the display";
};
description = mkOption {
description = "description of display from hyprctl monitors";
default = "";
};
scaling = mkOption {
type = types.float;
default = 1.0;
@ -83,6 +105,8 @@ in
{
wayland.windowManager.hyprland.extraConfig = mkIf (cfg.displays != [ ])
(renderDisplaysForHyprland cfg.displays);
systemd.user.services.swaybg = swaybgJob cfg.displays;
}
];
};

View file

@ -7,14 +7,15 @@ in
options.roles = {
laptop = {
enable = mkEnableOption "is a laptop";
displays = mkEnableOption "laptop display defaults";
};
};
config = mkIf cfg.enable {
displays = {
displays = mkIf cfg.displays {
enable = true;
displays = [{
name = "eDP-1";
name = "eDP-1";
scaling = 1.2;
}];
};

View file

@ -6,7 +6,7 @@ with lib;
};
config = mkIf config.roles.work.enable {
roles.email = {
enable = true;
email = "tristan.beedell@cryoserver.com";
@ -58,6 +58,7 @@ with lib;
userSettings = {
"aws.telemetry" = false;
"gitlens.telemetry.enabled" = false;
"redhat.telemetry.enabled" = false;
};
};