From a5f9c296699b78ff665965231f3dbc2597896bad Mon Sep 17 00:00:00 2001 From: Tristan Date: Thu, 11 May 2023 11:55:57 +0100 Subject: [PATCH] swaybg systemd service --- hardware/displays.nix | 22 ++++++++++++++++++++++ hardware/work.nix | 1 + lib/modules/display.nix | 34 +++++++++++++++++++++++++++++----- lib/modules/laptop.nix | 5 +++-- lib/modules/work.nix | 3 ++- system/global/home.nix | 9 +++++++-- 6 files changed, 64 insertions(+), 10 deletions(-) create mode 100644 hardware/displays.nix diff --git a/hardware/displays.nix b/hardware/displays.nix new file mode 100644 index 0000000..348c73c --- /dev/null +++ b/hardware/displays.nix @@ -0,0 +1,22 @@ +{ config, ... }: + +{ + displays = { + enable = true; + displays = [ + { + name = "DP-1"; + description = "HP Inc. HP 24x 1CR9500W9Q"; + resolution = { x = 1920; y = 1080; freq = 144; }; + position = "0x0"; + } + { + name = "eDP-1"; + description = "BOE 0x07D8"; + scaling = 1.2; + position = "0x1080"; + wallpaper = "/home/tristan/Pictures/backgrounds/nix-wallpaper-watersplash.png"; + } + ]; + }; +} diff --git a/hardware/work.nix b/hardware/work.nix index 053dcc4..d9b1e0d 100644 --- a/hardware/work.nix +++ b/hardware/work.nix @@ -7,6 +7,7 @@ imports = [ (modulesPath + "/installer/scan/not-detected.nix") + ./displays.nix ]; boot.initrd.availableKernelModules = [ "xhci_pci" "thunderbolt" "nvme" "usb_storage" "sd_mod" "sdhci_pci" ]; diff --git a/lib/modules/display.nix b/lib/modules/display.nix index 669f274..af3f753 100644 --- a/lib/modules/display.nix +++ b/lib/modules/display.nix @@ -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; } ]; }; diff --git a/lib/modules/laptop.nix b/lib/modules/laptop.nix index 2c2e776..e98b547 100644 --- a/lib/modules/laptop.nix +++ b/lib/modules/laptop.nix @@ -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; }]; }; diff --git a/lib/modules/work.nix b/lib/modules/work.nix index c24b0ba..63cb717 100644 --- a/lib/modules/work.nix +++ b/lib/modules/work.nix @@ -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; }; }; diff --git a/system/global/home.nix b/system/global/home.nix index 2abf786..e219d5b 100644 --- a/system/global/home.nix +++ b/system/global/home.nix @@ -44,6 +44,7 @@ in neofetch inkscape + libsForQt5.okular pavucontrol qpwgraph element-desktop @@ -392,9 +393,9 @@ in open = "$set -f; ${pkgs.ranger}/bin/rifle -p 0 \"$fx\""; open-with = ''''${{ set -f - ${pkgs.ranger}/bin/rifle -l $fx + ${pkgs.ranger}/bin/rifle -l "$fx" read -p "Open with: " method - ${pkgs.ranger}/bin/rifle -p $method $fx + ${pkgs.ranger}/bin/rifle -p "$method" "$fx" }}''; bulk-rename = ''''${{ old="$(mktemp)" @@ -858,6 +859,10 @@ color body red default "([a-z][a-z0-9+-]*://(((([a-z0-9_.!~*'();:&=+$,-]|%[0-9a- command = "${pkgs.gopls}/bin/gopls"; filetypes = [ "go" ]; }; + nix = { + command = "${pkgs.rnix-lsp}/bin/rnix-lsp"; + filetypes = [ "nix" ]; + }; }; }; };