From 75cdf136e3101f1f8afff41a0864e737937d8f1f Mon Sep 17 00:00:00 2001 From: Sam Date: Sat, 15 Jun 2024 01:20:42 +0100 Subject: [PATCH] modularise dwm --- flake.lock | 148 ++---------------- .../optional/desktop/cinnamon/autostart.nix | 0 .../optional/desktop/cinnamon/default.nix | 2 + .../optional/desktop/common/x11/default.nix | 52 +----- .../{ => scripts}/feh-wallpaper-changer.nix | 0 home/common/optional/desktop/dwm/default.nix | 44 ++---- home/common/optional/desktop/dwm/picom.nix | 17 ++ .../scripts/dunstify-volume-notification.nix | 0 home/common/optional/desktop/dwm/sxhkdrc.nix | 48 ++++++ home/common/optional/desktop/dwm/xinitrc.nix | 32 ++++ .../optional/desktop/dwm/xresources.nix | 14 ++ hosts/common/optional/pipewire.nix | 28 ++-- 12 files changed, 150 insertions(+), 235 deletions(-) create mode 100644 home/common/optional/desktop/cinnamon/autostart.nix rename home/common/optional/desktop/common/x11/{ => scripts}/feh-wallpaper-changer.nix (100%) create mode 100644 home/common/optional/desktop/dwm/picom.nix rename home/common/optional/desktop/{common/x11 => dwm}/scripts/dunstify-volume-notification.nix (100%) create mode 100644 home/common/optional/desktop/dwm/sxhkdrc.nix create mode 100644 home/common/optional/desktop/dwm/xinitrc.nix create mode 100644 home/common/optional/desktop/dwm/xresources.nix diff --git a/flake.lock b/flake.lock index c2e92b2..c32bfea 100644 --- a/flake.lock +++ b/flake.lock @@ -147,25 +147,7 @@ }, "flake-utils_3": { "inputs": { - "systems": "systems_4" - }, - "locked": { - "lastModified": 1710146030, - "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "flake-utils", - "type": "github" - } - }, - "flake-utils_4": { - "inputs": { - "systems": "systems_5" + "systems": "systems_3" }, "locked": { "lastModified": 1710146030, @@ -327,27 +309,6 @@ } }, "nix-github-actions": { - "inputs": { - "nixpkgs": [ - "poetry2nix", - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1703863825, - "narHash": "sha256-rXwqjtwiGKJheXB43ybM8NwWB8rO2dSRrEqes0S7F5Y=", - "owner": "nix-community", - "repo": "nix-github-actions", - "rev": "5163432afc817cf8bd1f031418d1869e4c9d5547", - "type": "github" - }, - "original": { - "owner": "nix-community", - "repo": "nix-github-actions", - "type": "github" - } - }, - "nix-github-actions_2": { "inputs": { "nixpkgs": [ "sqlfmt", @@ -445,22 +406,6 @@ } }, "nixpkgs_2": { - "locked": { - "lastModified": 1717926692, - "narHash": "sha256-THcv8qDqobZefHHluPjx/8n+MtVVb8ag/oJbKMqKNRo=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "7d916e720af6b2ca355e4d0cfb8e4f742c172239", - "type": "github" - }, - "original": { - "owner": "NixOS", - "ref": "nixos-unstable-small", - "repo": "nixpkgs", - "type": "github" - } - }, - "nixpkgs_3": { "locked": { "lastModified": 1718376599, "narHash": "sha256-cTFGqLYTrIxORc673fUUCecQVXiXHDj6Z8vFQ5K4SDg=", @@ -520,36 +465,14 @@ }, "poetry2nix": { "inputs": { - "flake-utils": "flake-utils_2", + "flake-utils": "flake-utils_3", "nix-github-actions": "nix-github-actions", - "nixpkgs": "nixpkgs_2", - "systems": "systems_3", - "treefmt-nix": "treefmt-nix_2" - }, - "locked": { - "lastModified": 1718285706, - "narHash": "sha256-DScsBM+kZvxOva7QegfdtleebMXh30XPxDQr/1IGKYo=", - "owner": "nix-community", - "repo": "poetry2nix", - "rev": "a5be1bbbe0af0266147a88e0ec43b18c722f2bb9", - "type": "github" - }, - "original": { - "owner": "nix-community", - "repo": "poetry2nix", - "type": "github" - } - }, - "poetry2nix_2": { - "inputs": { - "flake-utils": "flake-utils_4", - "nix-github-actions": "nix-github-actions_2", "nixpkgs": [ "sqlfmt", "nixpkgs" ], - "systems": "systems_6", - "treefmt-nix": "treefmt-nix_3" + "systems": "systems_4", + "treefmt-nix": "treefmt-nix_2" }, "locked": { "lastModified": 1718285706, @@ -576,7 +499,6 @@ "nixpkgs-unstable": "nixpkgs-unstable", "nixvim": "nixvim", "nur": "nur", - "poetry2nix": "poetry2nix", "sops-nix": "sops-nix", "sqlfmt": "sqlfmt" } @@ -604,9 +526,9 @@ }, "sqlfmt": { "inputs": { - "flake-utils": "flake-utils_3", - "nixpkgs": "nixpkgs_3", - "poetry2nix": "poetry2nix_2" + "flake-utils": "flake-utils_2", + "nixpkgs": "nixpkgs_2", + "poetry2nix": "poetry2nix" }, "locked": { "dir": "sqlfmt", @@ -664,41 +586,12 @@ "type": "github" }, "original": { - "id": "systems", - "type": "indirect" + "owner": "nix-systems", + "repo": "default", + "type": "github" } }, "systems_4": { - "locked": { - "lastModified": 1681028828, - "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", - "owner": "nix-systems", - "repo": "default", - "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", - "type": "github" - }, - "original": { - "owner": "nix-systems", - "repo": "default", - "type": "github" - } - }, - "systems_5": { - "locked": { - "lastModified": 1681028828, - "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", - "owner": "nix-systems", - "repo": "default", - "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", - "type": "github" - }, - "original": { - "owner": "nix-systems", - "repo": "default", - "type": "github" - } - }, - "systems_6": { "locked": { "lastModified": 1681028828, "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", @@ -734,27 +627,6 @@ } }, "treefmt-nix_2": { - "inputs": { - "nixpkgs": [ - "poetry2nix", - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1717850719, - "narHash": "sha256-npYqVg+Wk4oxnWrnVG7416fpfrlRhp/lQ6wQ4DHI8YE=", - "owner": "numtide", - "repo": "treefmt-nix", - "rev": "4fc1c45a5f50169f9f29f6a98a438fb910b834ed", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "treefmt-nix", - "type": "github" - } - }, - "treefmt-nix_3": { "inputs": { "nixpkgs": [ "sqlfmt", diff --git a/home/common/optional/desktop/cinnamon/autostart.nix b/home/common/optional/desktop/cinnamon/autostart.nix new file mode 100644 index 0000000..e69de29 diff --git a/home/common/optional/desktop/cinnamon/default.nix b/home/common/optional/desktop/cinnamon/default.nix index b46cc7d..092d169 100644 --- a/home/common/optional/desktop/cinnamon/default.nix +++ b/home/common/optional/desktop/cinnamon/default.nix @@ -1,6 +1,8 @@ { imports = [ ../common + ../common/x11 + ./autostart.nix # This doesn't seem to work in Cinnamon #./cinnamon-monitors.nix ]; diff --git a/home/common/optional/desktop/common/x11/default.nix b/home/common/optional/desktop/common/x11/default.nix index 8c9fb7a..c59cb66 100644 --- a/home/common/optional/desktop/common/x11/default.nix +++ b/home/common/optional/desktop/common/x11/default.nix @@ -1,62 +1,14 @@ { pkgs, ... }: { imports = [ - ./feh-wallpaper-changer.nix - ./scripts/dunstify-volume-notification.nix + ./scripts/feh-wallpaper-changer.nix ]; home.packages = [ - pkgs.dunst pkgs.flameshot pkgs.st - pkgs.dmenu - pkgs.picom pkgs.xclip - + pkgs.feh ]; - home.file.".Xresources" = { - recursive = true; - text = '' - !st terminal - st.alpha: 0.8 - *.font: monospace:pixelsize=21:antialias=true:autohint=true; - *.font2: NotoColorEmoji:pixelsize=19:antialias=true:autohint=true; - - ! dwm - dwm.borderpx: 3 - ''; - }; - - home.file.".config/picom/picom.conf" = { - recursive = true; - text = '' - vsync = true; - backend = "xrender"; - shadow = true; - shadow-radius = 10; - shadow-offset-x = -5; - shadow-offset-y = -5; - fading = true; - fade-in-step = 0.2; - fade-out-step = 0.2; - fade-delta = 50; - ''; - }; - - home.file.".config/sxhkd/sxhkdrc" = { - recursive = true; - text = '' - vsync = true; - backend = "xrender"; - shadow = true; - shadow-radius = 10; - shadow-offset-x = -5; - shadow-offset-y = -5; - fading = true; - fade-in-step = 0.2; - fade-out-step = 0.2; - fade-delta = 50; - ''; - }; } diff --git a/home/common/optional/desktop/common/x11/feh-wallpaper-changer.nix b/home/common/optional/desktop/common/x11/scripts/feh-wallpaper-changer.nix similarity index 100% rename from home/common/optional/desktop/common/x11/feh-wallpaper-changer.nix rename to home/common/optional/desktop/common/x11/scripts/feh-wallpaper-changer.nix diff --git a/home/common/optional/desktop/dwm/default.nix b/home/common/optional/desktop/dwm/default.nix index ee33da3..c27b85d 100644 --- a/home/common/optional/desktop/dwm/default.nix +++ b/home/common/optional/desktop/dwm/default.nix @@ -4,6 +4,10 @@ imports = [ ../common ../common/x11 + ./xinitrc.nix + ./sxhkdrc.nix + ./picom.nix + ./xresources.nix # Status bar scripts ./scripts/sb-cpu-pct.nix @@ -11,42 +15,16 @@ ./scripts/sb-volume.nix ./scripts/sb-network-status.nix ./scripts/sb-updates.nix + + # Notification scripts + ./scripts/dunstify-volume-notification.nix ]; home.packages = [ pkgs.dwmblocks + pkgs.dmenu + pkgs.dunst + pkgs.picom + pkgs.sxhkd ]; - - # TODO configure x11 to look in .config/x11 - #home.file."${config.xdg.configHome}/x11/xinitrc" = { - home.file.".xinitrc" = { - recursive = true; - text = '' - - picom -b --config ~/.config/picom/picom.conf - xrdb ~/.Xresources - - autostart="dwmblocks feh-wallpaper-changer" - - for program in $autostart; do - pidof -sx "$program" || "$program" & - done >/dev/null 2>&1 - - - if test -z "$DBUS_SESSION_BUS_ADDRESS"; then - eval $(dbus-launch --exit-with-session --sh-syntax) - fi - systemctl --user import-environment DISPLAY XAUTHORITY - - if command -v dbus-update-activation-environment >/dev/null 2>&1; then - dbus-update-activation-environment DISPLAY XAUTHORITY - fi - - export XSESSION_PID="$$" - exec dwm - - ''; - }; - - } diff --git a/home/common/optional/desktop/dwm/picom.nix b/home/common/optional/desktop/dwm/picom.nix new file mode 100644 index 0000000..e395d7b --- /dev/null +++ b/home/common/optional/desktop/dwm/picom.nix @@ -0,0 +1,17 @@ +{ + home.file.".config/picom/picom.conf" = { + recursive = true; + text = '' + vsync = true; + backend = "xrender"; + shadow = true; + shadow-radius = 10; + shadow-offset-x = -5; + shadow-offset-y = -5; + fading = true; + fade-in-step = 0.2; + fade-out-step = 0.2; + fade-delta = 50; + ''; + }; +} diff --git a/home/common/optional/desktop/common/x11/scripts/dunstify-volume-notification.nix b/home/common/optional/desktop/dwm/scripts/dunstify-volume-notification.nix similarity index 100% rename from home/common/optional/desktop/common/x11/scripts/dunstify-volume-notification.nix rename to home/common/optional/desktop/dwm/scripts/dunstify-volume-notification.nix diff --git a/home/common/optional/desktop/dwm/sxhkdrc.nix b/home/common/optional/desktop/dwm/sxhkdrc.nix new file mode 100644 index 0000000..1b60de5 --- /dev/null +++ b/home/common/optional/desktop/dwm/sxhkdrc.nix @@ -0,0 +1,48 @@ +{ + home.file.".config/sxhkd/sxhkdrc" = { + recursive = true; + text = '' + XF86AudioRaiseVolume + pamixer --set-limit 150 --allow-boost -i 5 && dunstify-volume-notification && pkill -RTMIN+10 dwmblocks && exit 1 + + XF86AudioLowerVolume + pamixer --set-limit 150 --allow-boost -d 5 && dunstify-volume-notification && pkill -RTMIN+10 dwmblocks && exit 1 + + XF86AudioMute + pamixer --toggle-mute && dunstify-volume-notification && pkill -RTMIN+10 dwmblocks && exit 1 + + XF86AudioMicMute + pamixer --default-source --toggle-mute && dunstify-volume-notification && pkill -RTMIN+10 dwmblocks && exit 1 + + XF86MonBrightnessUp + light -A 5 && dunstify-brightness-notification + + XF86MonBrightnessDown + light -U 5 && dunstify-brightness-notification + + XF86Messenger + dunstify-battery-notification + + control + Home + bookmark-add + + control + Insert + bookmark-insert + + control + F12 + nsxiv-clipboard-copy /tmp/clipboard/images/ + + Print + flameshot gui + + control + F11 + dmenu-clipper + + control + F8 + dmenu-dict + + control + F7 + emoji-picker + ''; + }; +} diff --git a/home/common/optional/desktop/dwm/xinitrc.nix b/home/common/optional/desktop/dwm/xinitrc.nix new file mode 100644 index 0000000..51ee978 --- /dev/null +++ b/home/common/optional/desktop/dwm/xinitrc.nix @@ -0,0 +1,32 @@ +{ + # TODO configure x11 to look in .config/x11 + #home.file."${config.xdg.configHome}/x11/xinitrc" = { + home.file.".xinitrc" = { + recursive = true; + text = '' + + picom -b --config ~/.config/picom/picom.conf + xrdb ~/.Xresources + + autostart="dwmblocks feh-wallpaper-changer" + + for program in $autostart; do + pidof -sx "$program" || "$program" & + done >/dev/null 2>&1 + + + if test -z "$DBUS_SESSION_BUS_ADDRESS"; then + eval $(dbus-launch --exit-with-session --sh-syntax) + fi + systemctl --user import-environment DISPLAY XAUTHORITY + + if command -v dbus-update-activation-environment >/dev/null 2>&1; then + dbus-update-activation-environment DISPLAY XAUTHORITY + fi + + export XSESSION_PID="$$" + exec dwm + + ''; + }; +} diff --git a/home/common/optional/desktop/dwm/xresources.nix b/home/common/optional/desktop/dwm/xresources.nix new file mode 100644 index 0000000..df23d70 --- /dev/null +++ b/home/common/optional/desktop/dwm/xresources.nix @@ -0,0 +1,14 @@ +{ + home.file.".Xresources" = { + recursive = true; + text = '' + !st terminal + st.alpha: 0.8 + *.font: monospace:pixelsize=21:antialias=true:autohint=true; + *.font2: NotoColorEmoji:pixelsize=19:antialias=true:autohint=true; + + ! dwm + dwm.borderpx: 3 + ''; + }; +} diff --git a/hosts/common/optional/pipewire.nix b/hosts/common/optional/pipewire.nix index 26948ee..70b8fe6 100644 --- a/hosts/common/optional/pipewire.nix +++ b/hosts/common/optional/pipewire.nix @@ -1,21 +1,21 @@ { pkgs, ... }: { sound.enable = true; - hardware.pulseaudio.enable = true; + #hardware.pulseaudio.enable = true; security.rtkit.enable = true; - hardware.pulseaudio.package = pkgs.pulseaudioFull; -# services.pipewire = { -# enable = true; -# alsa.enable = true; -# alsa.support32Bit = true; -# pulse.enable = true; -# wireplumber.enable = true; -# jack.enable = true; -# -# }; + #hardware.pulseaudio.package = pkgs.pulseaudioFull; + services.pipewire = { + enable = true; + alsa.enable = true; + alsa.support32Bit = true; + pulse.enable = true; + wireplumber.enable = true; + jack.enable = true; -environment.systemPackages = [ - pkgs.pamixer - pkgs.pavucontrol + }; + + environment.systemPackages = [ + pkgs.pamixer + pkgs.pavucontrol ]; }