From c0125934417ad6bbdc97ec7787d172b79d680455 Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Fri, 3 Jan 2025 22:46:50 +0100 Subject: [PATCH 01/24] Update youmubot --- flake.lock | 43 +++++++++++++++++++------------------------ flake.nix | 2 +- 2 files changed, 20 insertions(+), 25 deletions(-) diff --git a/flake.lock b/flake.lock index 8dec570..bf0c75d 100644 --- a/flake.lock +++ b/flake.lock @@ -153,18 +153,12 @@ } }, "crane_5": { - "inputs": { - "nixpkgs": [ - "youmubot", - "nixpkgs" - ] - }, "locked": { - "lastModified": 1724377159, - "narHash": "sha256-ixjje1JO8ucKT41hs6n2NCde1Vc0+Zc2p2gUbJpCsMw=", + "lastModified": 1734744351, + "narHash": "sha256-fN9npuZHHHzDVr1wuKoh/TheHkerDaLB9l4vj/48Exg=", "owner": "ipetkov", "repo": "crane", - "rev": "3e47b7a86c19142bd3675da49d6acef488b4dac1", + "rev": "a83a48a62640517588c3d137c948ed034706363c", "type": "github" }, "original": { @@ -578,11 +572,11 @@ "systems": "systems_8" }, "locked": { - "lastModified": 1710146030, - "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", + "lastModified": 1731533236, + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", "owner": "numtide", "repo": "flake-utils", - "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", "type": "github" }, "original": { @@ -1026,11 +1020,11 @@ }, "nixpkgs_10": { "locked": { - "lastModified": 1724224976, - "narHash": "sha256-Z/ELQhrSd7bMzTO8r7NZgi9g5emh+aRKoCdaAv5fiO0=", + "lastModified": 1734424634, + "narHash": "sha256-cHar1vqHOOyC7f1+tVycPoWTfKIaqkoe1Q6TnKzuti4=", "owner": "nixos", "repo": "nixpkgs", - "rev": "c374d94f1536013ca8e92341b540eba4c22f9c62", + "rev": "d3c42f187194c26d9f0309a8ecc469d6c878ce33", "type": "github" }, "original": { @@ -1304,11 +1298,11 @@ ] }, "locked": { - "lastModified": 1724466314, - "narHash": "sha256-ltKuK6shQ64uej1mYNtBsDYxttUNFiv9AcHqk0+0NQM=", + "lastModified": 1734747996, + "narHash": "sha256-0DUuObdcPITVOMMymq2y6YlM++QEWXZO3cTm6RGYgL8=", "owner": "oxalica", "repo": "rust-overlay", - "rev": "2b5b3edd96ef336b00622dcabc13788fdef9e3ca", + "rev": "f9086701f5f3d36b8e5f4a3b9c93579ebc2581e6", "type": "github" }, "original": { @@ -1325,11 +1319,11 @@ ] }, "locked": { - "lastModified": 1724466314, - "narHash": "sha256-ltKuK6shQ64uej1mYNtBsDYxttUNFiv9AcHqk0+0NQM=", + "lastModified": 1734747996, + "narHash": "sha256-0DUuObdcPITVOMMymq2y6YlM++QEWXZO3cTm6RGYgL8=", "owner": "oxalica", "repo": "rust-overlay", - "rev": "2b5b3edd96ef336b00622dcabc13788fdef9e3ca", + "rev": "f9086701f5f3d36b8e5f4a3b9c93579ebc2581e6", "type": "github" }, "original": { @@ -1550,15 +1544,16 @@ "rust-overlay": "rust-overlay_4" }, "locked": { - "lastModified": 1731934405, - "narHash": "sha256-5lRtAsJjjc9BkTbpuhjgMgDpXKYkYcGDydh+xJzDVyU=", + "lastModified": 1735912896, + "narHash": "sha256-jJQfnP7XhTGlCvUIgxIKDipIkif/AmOk6SgSuD5qils=", "owner": "natsukagami", "repo": "youmubot", - "rev": "a4fab5438bebd9c399f628151958789c7f2454a6", + "rev": "dde4a722a07ba6ad814b3792ae1361139be1e973", "type": "github" }, "original": { "owner": "natsukagami", + "ref": "osu-commands", "repo": "youmubot", "type": "github" } diff --git a/flake.nix b/flake.nix index 8511cee..b3422e6 100644 --- a/flake.nix +++ b/flake.nix @@ -37,7 +37,7 @@ # --- # Imported apps - youmubot.url = "github:natsukagami/youmubot"; + youmubot.url = "github:natsukagami/youmubot/osu-commands"; # swayfx = { # url = github:WillPower3309/swayfx; # inputs.nixpkgs.follows = "nixpkgs"; From c9028042815f4eebe0ce29ce724803b918778606 Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Sun, 5 Jan 2025 14:17:56 +0100 Subject: [PATCH 02/24] Update osu --- home/osu.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/home/osu.nix b/home/osu.nix index baef84b..07f4cf1 100644 --- a/home/osu.nix +++ b/home/osu.nix @@ -5,10 +5,10 @@ let osu-pkg = with pkgs; with lib; appimageTools.wrapType2 rec { pname = "osu-lazer-bin"; - version = "2024.1219.2"; + version = "2025.101.0"; src = fetchurl { url = "https://github.com/ppy/osu/releases/download/${version}/osu.AppImage"; - hash = "sha256-gRUr7jf0+Xbfz8FurPk/o7F67TYisdNySNzVWEMb1es="; + hash = "sha256-GsnTxVpNk2RXHLET6Ugv0/ZOlq8RUkw2ZXqRjkU+dzw="; }; extraPkgs = pkgs: with pkgs; [ icu ]; From ad563100c4ad07594ca17860b6e98329e52bd9fe Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Thu, 9 Jan 2025 15:56:08 +0100 Subject: [PATCH 03/24] Update nixpkgs-unstable --- flake.lock | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/flake.lock b/flake.lock index bf0c75d..d00dc99 100644 --- a/flake.lock +++ b/flake.lock @@ -724,11 +724,11 @@ ] }, "locked": { - "lastModified": 1732884235, - "narHash": "sha256-r8j6R3nrvwbT1aUp4EPQ1KC7gm0pu9VcV1aNaB+XG6Q=", + "lastModified": 1736066484, + "narHash": "sha256-uTstP36WaFrw+TEHb8nLF14hFPzQBOhmIxzioHCDaL8=", "owner": "nix-community", "repo": "home-manager", - "rev": "819f682269f4e002884702b87e445c82840c68f2", + "rev": "5ad12b6ea06b84e48f6b677957c74f32d47bdee0", "type": "github" }, "original": { @@ -1004,11 +1004,11 @@ }, "nixpkgs-unstable": { "locked": { - "lastModified": 1734126203, - "narHash": "sha256-0XovF7BYP50rTD2v4r55tR5MuBLet7q4xIz6Rgh3BBU=", + "lastModified": 1735915915, + "narHash": "sha256-Q4HuFAvoKAIiTRZTUxJ0ZXeTC7lLfC9/dggGHNXNlCw=", "owner": "nixos", "repo": "nixpkgs", - "rev": "71a6392e367b08525ee710a93af2e80083b5b3e2", + "rev": "a27871180d30ebee8aa6b11bf7fef8a52f024733", "type": "github" }, "original": { From e0a6477d4f02cf8719affb0f2b386ed88e479964 Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Mon, 13 Jan 2025 11:11:53 +0100 Subject: [PATCH 04/24] Switch typst-lsp to tinymist --- home/kakoune/kak.nix | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/home/kakoune/kak.nix b/home/kakoune/kak.nix index aad934c..ef7963e 100644 --- a/home/kakoune/kak.nix +++ b/home/kakoune/kak.nix @@ -156,13 +156,14 @@ in }; package = pkgs.texlab; }; - programs.kak-lsp.languageServers.typst-lsp = { - command = "typst-lsp"; + programs.kak-lsp.languageServers.tinymist = { + command = "tinymist"; filetypes = [ "typst" ]; roots = [ "main.typ" ".git" ]; - settings_section = "typst-lsp"; - settings.typst-lsp = { - experimentalFormatterMode = "on"; + settings_section = "tinymist"; + settings.tinymist = { + exportPdf = "onSave"; + formatterMode = "typstfmt"; }; }; programs.kak-lsp.languageServers.marksman = { From b8dee3e2081384f947c84ec55b2d4e14454092ed Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Thu, 16 Jan 2025 14:43:27 +0100 Subject: [PATCH 05/24] Update nixpkgs --- flake.lock | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/flake.lock b/flake.lock index d00dc99..efb63dd 100644 --- a/flake.lock +++ b/flake.lock @@ -703,11 +703,11 @@ ] }, "locked": { - "lastModified": 1733050161, - "narHash": "sha256-lYnT+EYE47f5yY3KS/Kd4pJ6CO9fhCqumkYYkQ3TK20=", + "lastModified": 1736373539, + "narHash": "sha256-dinzAqCjenWDxuy+MqUQq0I4zUSfaCvN9rzuCmgMZJY=", "owner": "nix-community", "repo": "home-manager", - "rev": "62d536255879be574ebfe9b87c4ac194febf47c5", + "rev": "bd65bc3cde04c16755955630b344bc9e35272c56", "type": "github" }, "original": { @@ -1164,11 +1164,11 @@ }, "nixpkgs_9": { "locked": { - "lastModified": 1734083684, - "narHash": "sha256-5fNndbndxSx5d+C/D0p/VF32xDiJCJzyOqorOYW4JEo=", + "lastModified": 1736549401, + "narHash": "sha256-ibkQrMHxF/7TqAYcQE+tOnIsSEzXmMegzyBWza6uHKM=", "owner": "nixos", "repo": "nixpkgs", - "rev": "314e12ba369ccdb9b352a4db26ff419f7c49fa84", + "rev": "1dab772dd4a68a7bba5d9460685547ff8e17d899", "type": "github" }, "original": { From 7a283f4bbca19eb8d4e9ea3ec1721e40717f27df Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Mon, 30 Dec 2024 13:50:29 +0100 Subject: [PATCH 06/24] Use latest kernel on framework --- nki-framework/hardware-configuration.nix | 1 - 1 file changed, 1 deletion(-) diff --git a/nki-framework/hardware-configuration.nix b/nki-framework/hardware-configuration.nix index e88c852..c814573 100644 --- a/nki-framework/hardware-configuration.nix +++ b/nki-framework/hardware-configuration.nix @@ -12,7 +12,6 @@ boot.initrd.availableKernelModules = [ "nvme" "xhci_pci" "thunderbolt" "usb_storage" "sd_mod" ]; boot.initrd.kernelModules = [ ]; boot.kernelModules = [ "kvm-amd" ]; - boot.kernelPackages = pkgs.linuxPackages; # until mesa fixed boot.kernelParams = [ # Hibernation "resume=UUID=fa8aaf51-b99f-4fb4-9230-8c0957d8af3f" From 65410deb2fa1519a784c89d4b5a4f81f22169443 Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Mon, 30 Dec 2024 13:52:43 +0100 Subject: [PATCH 07/24] Add associations for telegram --- home/modules/linux/graphical/default.nix | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/home/modules/linux/graphical/default.nix b/home/modules/linux/graphical/default.nix index 35a29eb..499088a 100644 --- a/home/modules/linux/graphical/default.nix +++ b/home/modules/linux/graphical/default.nix @@ -131,6 +131,8 @@ in "x-scheme-handler/feed" = [ "thunderbird.desktop" ]; "application/rss+xml" = [ "thunderbird.desktop" ]; "application/x-extension-rss" = [ "thunderbird.desktop" ]; + "x-scheme-handler/tg2" = [ "org.telegram.desktop.desktop" ]; + "x-scheme-handler/tonsite2" = [ "org.telegram.desktop.desktop" ]; }; xdg.mimeApps.defaultApplications = { # Email @@ -167,6 +169,10 @@ in # Files "inode/directory" = [ "dolphin.desktop" ]; + + # Telegram + "x-scheme-handler/tg2" = "org.telegram.desktop.desktop"; + "x-scheme-handler/tonsite2" = "org.telegram.desktop.desktop"; }; # Add one for kakoune From 73764de6f415f808d1971aec6401d8efe34bfdd0 Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Sat, 4 Jan 2025 15:48:03 +0100 Subject: [PATCH 08/24] Set diff conflictStyle to zdiff3 https://github.blog/open-source/git/highlights-from-git-2-35/ https://git-scm.com/docs/git-config#Documentation/git-config.txt-mergeconflictStyle --- home/common.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/home/common.nix b/home/common.nix index 2034fce..4d34941 100644 --- a/home/common.nix +++ b/home/common.nix @@ -106,7 +106,7 @@ .kakrc ''}"; safe.directory = "*"; - merge.conflictstyle = "diff3"; + merge.conflictstyle = "zdiff3"; }; }; From b47c13665080927d0e00175fad08cb52ebb5abed Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Tue, 14 Jan 2025 02:04:17 +0100 Subject: [PATCH 09/24] Update nixpkgs-unstable --- flake.lock | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/flake.lock b/flake.lock index efb63dd..5ee49ce 100644 --- a/flake.lock +++ b/flake.lock @@ -724,11 +724,11 @@ ] }, "locked": { - "lastModified": 1736066484, - "narHash": "sha256-uTstP36WaFrw+TEHb8nLF14hFPzQBOhmIxzioHCDaL8=", + "lastModified": 1736785676, + "narHash": "sha256-TY0jUwR3EW0fnS0X5wXMAVy6h4Z7Y6a3m+Yq++C9AyE=", "owner": "nix-community", "repo": "home-manager", - "rev": "5ad12b6ea06b84e48f6b677957c74f32d47bdee0", + "rev": "fc52a210b60f2f52c74eac41a8647c1573d2071d", "type": "github" }, "original": { @@ -1004,11 +1004,11 @@ }, "nixpkgs-unstable": { "locked": { - "lastModified": 1735915915, - "narHash": "sha256-Q4HuFAvoKAIiTRZTUxJ0ZXeTC7lLfC9/dggGHNXNlCw=", + "lastModified": 1736755442, + "narHash": "sha256-a3MMEY7i/wdF0gb7WFNTn6onzaiMOvwj7OerRVenA8o=", "owner": "nixos", "repo": "nixpkgs", - "rev": "a27871180d30ebee8aa6b11bf7fef8a52f024733", + "rev": "ef56e777fedaa4da8c66a150081523c5de1e0171", "type": "github" }, "original": { From 2edd5c93099fb5239fbc71dd0ed0114791b5264f Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Wed, 15 Jan 2025 12:21:10 +0100 Subject: [PATCH 10/24] Add niri flake and overlay --- flake.lock | 148 ++++++++++++++++++++++++++++++++++++++++++++++++++-- flake.nix | 1 + overlay.nix | 1 + 3 files changed, 145 insertions(+), 5 deletions(-) diff --git a/flake.lock b/flake.lock index 5ee49ce..5f65832 100644 --- a/flake.lock +++ b/flake.lock @@ -852,6 +852,62 @@ "type": "github" } }, + "niri": { + "inputs": { + "niri-stable": "niri-stable", + "niri-unstable": "niri-unstable", + "nixpkgs": "nixpkgs_8", + "nixpkgs-stable": "nixpkgs-stable_3", + "xwayland-satellite-stable": "xwayland-satellite-stable", + "xwayland-satellite-unstable": "xwayland-satellite-unstable" + }, + "locked": { + "lastModified": 1736884105, + "narHash": "sha256-WHxMcVuEmJvToC5DEVnSLwUrpHgJyqUqd/O8gZuaQsU=", + "owner": "sodiboo", + "repo": "niri-flake", + "rev": "a4e712bccfbe0526327c10b67f765b49cbbd7701", + "type": "github" + }, + "original": { + "owner": "sodiboo", + "repo": "niri-flake", + "type": "github" + } + }, + "niri-stable": { + "flake": false, + "locked": { + "lastModified": 1736614405, + "narHash": "sha256-AJ1rlgNOPb3/+DbS5hkhm21t6Oz8IgqLllwmZt0lyzk=", + "owner": "YaLTeR", + "repo": "niri", + "rev": "e05bc269e678ecf828b96ae79c991c13b00b38a5", + "type": "github" + }, + "original": { + "owner": "YaLTeR", + "ref": "v25.01", + "repo": "niri", + "type": "github" + } + }, + "niri-unstable": { + "flake": false, + "locked": { + "lastModified": 1736879117, + "narHash": "sha256-elG0TiWNFwgfTLrTTZVZQp3dEN6F6Qds6UF6BVxCIHs=", + "owner": "YaLTeR", + "repo": "niri", + "rev": "a3cbe3514ba195bf74815008f75819944f888527", + "type": "github" + }, + "original": { + "owner": "YaLTeR", + "repo": "niri", + "type": "github" + } + }, "nix-filter": { "locked": { "lastModified": 1705332318, @@ -870,7 +926,7 @@ "nix-gaming": { "inputs": { "flake-parts": "flake-parts_5", - "nixpkgs": "nixpkgs_8", + "nixpkgs": "nixpkgs_9", "umu": "umu" }, "locked": { @@ -1002,6 +1058,22 @@ "type": "github" } }, + "nixpkgs-stable_3": { + "locked": { + "lastModified": 1736754065, + "narHash": "sha256-hcETjfECLklW1ND8svDvN0Nw6H/1qtuoz3rbFNQ1Lrk=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "67e9c880898889470f153157a96b595e758167fc", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-24.11", + "repo": "nixpkgs", + "type": "github" + } + }, "nixpkgs-unstable": { "locked": { "lastModified": 1736755442, @@ -1019,6 +1091,22 @@ } }, "nixpkgs_10": { + "locked": { + "lastModified": 1734083684, + "narHash": "sha256-5fNndbndxSx5d+C/D0p/VF32xDiJCJzyOqorOYW4JEo=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "314e12ba369ccdb9b352a4db26ff419f7c49fa84", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-24.11", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_11": { "locked": { "lastModified": 1734424634, "narHash": "sha256-cHar1vqHOOyC7f1+tVycPoWTfKIaqkoe1Q6TnKzuti4=", @@ -1034,7 +1122,7 @@ "type": "github" } }, - "nixpkgs_11": { + "nixpkgs_12": { "locked": { "lastModified": 1734424634, "narHash": "sha256-cHar1vqHOOyC7f1+tVycPoWTfKIaqkoe1Q6TnKzuti4=", @@ -1147,6 +1235,22 @@ } }, "nixpkgs_8": { + "locked": { + "lastModified": 1736798957, + "narHash": "sha256-qwpCtZhSsSNQtK4xYGzMiyEDhkNzOCz/Vfu4oL2ETsQ=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "9abb87b552b7f55ac8916b6fc9e5cb486656a2f3", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_9": { "locked": { "lastModified": 1723856861, "narHash": "sha256-OTDg91+Zzs2SpU3csK4xVdSQFoG8cK1lNUwKmTqERyE=", @@ -1221,10 +1325,11 @@ "lanzaboote": "lanzaboote", "lix-module": "lix-module", "mpd-mpris": "mpd-mpris", + "niri": "niri", "nix-gaming": "nix-gaming", "nixos-hardware": "nixos-hardware", "nixos-m1": "nixos-m1", - "nixpkgs": "nixpkgs_9", + "nixpkgs": "nixpkgs_10", "nixpkgs-unstable": "nixpkgs-unstable", "rust-overlay": "rust-overlay_3", "secrets": "secrets", @@ -1536,11 +1641,44 @@ "type": "github" } }, + "xwayland-satellite-stable": { + "flake": false, + "locked": { + "lastModified": 1730166465, + "narHash": "sha256-nq7bouXQXaaPPo/E+Jbq+wNHnatD4dY8OxSrRqzvy6s=", + "owner": "Supreeeme", + "repo": "xwayland-satellite", + "rev": "a713cf46cb7db84a0d1b57c3a397c610cad3cf98", + "type": "github" + }, + "original": { + "owner": "Supreeeme", + "ref": "v0.5", + "repo": "xwayland-satellite", + "type": "github" + } + }, + "xwayland-satellite-unstable": { + "flake": false, + "locked": { + "lastModified": 1736487362, + "narHash": "sha256-4kGoOA7FgK9N2mzS+TFEn41kUUNY6KwdiA/0rqlr868=", + "owner": "Supreeeme", + "repo": "xwayland-satellite", + "rev": "8f55e27f63a749881c4bbfbb6b1da028342a91d1", + "type": "github" + }, + "original": { + "owner": "Supreeeme", + "repo": "xwayland-satellite", + "type": "github" + } + }, "youmubot": { "inputs": { "crane": "crane_5", "flake-utils": "flake-utils_9", - "nixpkgs": "nixpkgs_10", + "nixpkgs": "nixpkgs_11", "rust-overlay": "rust-overlay_4" }, "locked": { @@ -1560,7 +1698,7 @@ }, "zen-browser": { "inputs": { - "nixpkgs": "nixpkgs_11", + "nixpkgs": "nixpkgs_12", "zen-browser-aarch64": "zen-browser-aarch64", "zen-browser-generic": "zen-browser-generic", "zen-browser-specific": "zen-browser-specific" diff --git a/flake.nix b/flake.nix index b3422e6..9de728a 100644 --- a/flake.nix +++ b/flake.nix @@ -50,6 +50,7 @@ conduit.url = "gitlab:famedly/conduit/v0.9.0"; nix-gaming.url = github:fufexan/nix-gaming; zen-browser.url = "github:youwen5/zen-browser-flake"; + niri.url = "github:sodiboo/niri-flake"; # --- Sources kakoune.url = github:mawww/kakoune; diff --git a/overlay.nix b/overlay.nix index 4ad7209..1e60c41 100644 --- a/overlay.nix +++ b/overlay.nix @@ -120,6 +120,7 @@ in inputs.mpd-mpris.overlays.default inputs.rust-overlay.overlays.default inputs.youmubot.overlays.default + inputs.niri.overlays.niri overlay-unstable overlay-needs-unstable From c20ef04bfd355c04a4797a49c40b61d7d4cef189 Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Wed, 15 Jan 2025 12:23:47 +0100 Subject: [PATCH 11/24] Add niri nixosModule --- flake.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/flake.nix b/flake.nix index 9de728a..19e21d2 100644 --- a/flake.nix +++ b/flake.nix @@ -122,6 +122,7 @@ (common-nix stable) inputs.secrets.nixosModules.common inputs.nix-gaming.nixosModules.pipewireLowLatency + inputs.niri.nixosModules.niri ]; }; From 076079aea1a0873651aa28eafc7b5776ced366a9 Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Wed, 15 Jan 2025 12:45:31 +0100 Subject: [PATCH 12/24] Move waybar to its own module --- home/common.nix | 1 + home/kagami-pc-home.nix | 6 +- home/macbook-nixos.nix | 4 +- home/modules/linux/graphical/wayland.nix | 2 +- home/modules/programs/my-sway/default.nix | 410 +--------------------- home/modules/programs/my-waybar.nix | 408 +++++++++++++++++++++ home/nki-framework.nix | 2 +- 7 files changed, 431 insertions(+), 402 deletions(-) create mode 100644 home/modules/programs/my-waybar.nix diff --git a/home/common.nix b/home/common.nix index 4d34941..0768e21 100644 --- a/home/common.nix +++ b/home/common.nix @@ -5,6 +5,7 @@ ./kakoune/kak.nix ./fish/fish.nix ./modules/programs/my-broot.nix + ./modules/programs/my-waybar.nix ./modules/programs/my-sway ./modules/programs/my-kitty ./modules/programs/openconnect-epfl.nix diff --git a/home/kagami-pc-home.nix b/home/kagami-pc-home.nix index 2d0d7ab..539cfe9 100644 --- a/home/kagami-pc-home.nix +++ b/home/kagami-pc-home.nix @@ -45,8 +45,8 @@ linux.graphical.defaults.webBrowser = "zen.desktop"; programs.my-sway.enable = true; programs.my-sway.fontSize = 15.0; - programs.my-sway.enableLaptopBars = false; - programs.my-sway.enableMpd = true; + programs.my-sway.enableLaptop = true; + programs.my-waybar.enableMpd = true; # Keyboard options wayland.windowManager.sway.config.input."type:keyboard".xkb_layout = "jp"; wayland.windowManager.sway.config.input."type:pointer".accel_profile = "flat"; @@ -68,7 +68,7 @@ }; nki.programs.kitty.enable = true; nki.programs.kitty.fontSize = 14; - programs.my-sway.waybar.makeBars = with config.common.monitors; barWith: [ + programs.my-waybar.makeBars = with config.common.monitors; barWith: [ # For primary (barWith { extraSettings = { output = [ home_4k.name ]; }; }) # For secondary, hide mpd diff --git a/home/macbook-nixos.nix b/home/macbook-nixos.nix index d8dc729..ddd03e0 100644 --- a/home/macbook-nixos.nix +++ b/home/macbook-nixos.nix @@ -50,8 +50,8 @@ in # Enable sway programs.my-sway.enable = true; programs.my-sway.fontSize = 14.0; - programs.my-sway.enableLaptopBars = true; - programs.my-sway.enableMpd = false; + programs.my-sway.enableLaptop = true; + programs.my-waybar.enableMpd = false; programs.my-sway.discord = "${discord}/bin/armcord"; # Keyboard options wayland.windowManager.sway.config.input."type:keyboard".xkb_layout = "jp"; diff --git a/home/modules/linux/graphical/wayland.nix b/home/modules/linux/graphical/wayland.nix index 3c6cbd9..2763c99 100644 --- a/home/modules/linux/graphical/wayland.nix +++ b/home/modules/linux/graphical/wayland.nix @@ -13,7 +13,7 @@ let systemd.user.services.swaync.Install.WantedBy = lib.mkForce [ "sway-session.target" ]; systemd.user.services.swaync.Unit.PartOf = lib.mkForce [ "sway-session.target" ]; - programs.my-sway.waybar = { + programs.my-waybar = { extraSettings = [{ modules-right = mkAfter [ "custom/swaync" ]; modules."custom/swaync" = { diff --git a/home/modules/programs/my-sway/default.nix b/home/modules/programs/my-sway/default.nix index 428c56e..138dcab 100644 --- a/home/modules/programs/my-sway/default.nix +++ b/home/modules/programs/my-sway/default.nix @@ -44,10 +44,7 @@ let ${pkgs.grim}/bin/grim -g (${pkgs.slurp}/bin/slurp) - | ${pkgs.swappy}/bin/swappy -f - ''; - - ignored-devices = [ "Surface_Headphones" ]; - playerctl = "${pkgs.playerctl}/bin/playerctl --ignore-player=${strings.concatStringsSep "," ignored-devices}"; - + playerctl = "${pkgs.playerctl}/bin/playerctl"; in { # imports = [ ./ibus.nix ]; @@ -79,6 +76,12 @@ in default = "${pkgs.firefox-wayland}/bin/firefox"; }; + enableLaptop = lib.mkOption { + type = lib.types.bool; + description = "Whether to enable laptop-specific stuff"; + default = true; + }; + lockCmd = mkOption { type = types.str; description = "The screen lock command"; @@ -86,34 +89,14 @@ in + (if cfg.wallpaper == "" then "" else " -i ${cfg.wallpaper} -s fill") + " -l -k"; }; - enableLaptopBars = mkOption { - type = types.bool; - description = "Whether to enable laptop-specific bars (battery)"; - default = true; - }; - enableMpd = mkOption { - type = types.bool; - description = "Whether to enable mpd on waybar"; - default = false; - }; + }; - waybar = { - makeBars = mkOption { - type = types.raw; - description = "Create bars with the barWith function, return a list of bars"; - default = barWith: [ (barWith { }) ]; - }; - extraSettings = mkOption { - type = types.listOf types.raw; - description = "Extra settings to be included with every default bar"; - default = [ ]; - }; - extraStyle = mkOption { - type = types.lines; - description = "Additional style for the default waybar"; - default = ""; - }; - }; + # Enable waybar + config.programs.my-waybar = mkIf cfg.enable { + enable = true; + fontSize = mkDefault cfg.fontSize; + enableLaptopBars = mkDefault cfg.enableLaptop; + terminal = mkDefault cfg.terminal; }; config.wayland.windowManager.sway = mkIf cfg.enable { @@ -366,7 +349,7 @@ in wrapperFeatures.gtk = true; extraConfig = - (if cfg.enableLaptopBars then '' + (if cfg.enableLaptop then '' # Lock screen on lid close bindswitch lid:off exec ${cfg.lockCmd} @@ -409,369 +392,6 @@ in ]; }; - config.programs.waybar = - let - barWith = { showMedia ? true, showConnectivity ? true, extraSettings ? { }, ... }: mkMerge ([{ - position = "top"; - modules-left = [ - "sway/workspaces" - "sway/mode" - "sway/window" - ]; - modules-center = [ - ]; - modules-right = - lib.optional showMedia (if cfg.enableMpd then "mpd" else "custom/media") - ++ [ - "tray" - "pulseaudio" - ] ++ lib.optionals showConnectivity [ - "bluetooth" - "network" - ] ++ [ - "cpu" - "memory" - "temperature" - ] ++ lib.optionals cfg.enableLaptopBars [ "battery" "battery#bat2" ] - ++ [ - "clock" - ]; - - modules = { - "sway/workspaces" = { - format = "{name}"; - }; - "sway/mode" = { - format = "{}"; - }; - "sway/window" = { - max-length = 70; - format = "{title}"; - "rewrite" = { - "(.*) — Mozilla Firefox" = "[🌎] $1"; - "(.*) - Mozilla Thunderbird" = "[📧] $1"; - "(.*) - Kakoune" = "[⌨️] $1"; - "(.*) - fish" = "[>_] $1"; - "(.*) - Discord" = "[🗨️] $1"; - # ArmCord thing - "• Discord \\| (.*)" = "[🗨️] $1"; - "\\((\\d+)\\) Discord \\| (.*)" = "[🗨️] {$1} $2"; - }; - }; - "tray" = { - icon-size = 21; - spacing = 10; - }; - "clock" = { - # format = "{:📅 %Y-%m-%d | 🕰️ %H:%M [%Z]}"; - format = "📅 {0:%Y-%m-%d} |️ 🕰️ {0:%H:%M [%Z]}"; - tooltip-format = "\n{calendar}"; - timezones = [ - "Europe/Zurich" - "America/Toronto" - "Asia/Tokyo" - "Asia/Ho_Chi_Minh" - ]; - calendar = { - mode = "year"; - mode-mon-col = 3; - weeks-pos = "right"; - on-scroll = 1; - on-click-right = "mode"; - format = { - months = "{}"; - days = "{}"; - weeks = "W{}"; - weekdays = "日 月 火 水 木 金 土"; # See https://github.com/Alexays/Waybar/issues/3132 - today = "{}"; - }; - }; - actions = { - on-click-middle = "mode"; - on-click-right = "tz_up"; - on-scroll-up = "shift_up"; - on-scroll-down = "shift_down"; - }; - }; - "cpu" = { - format = "{usage}% "; - }; - "memory" = { - format = "{}% "; - }; - "temperature" = { - # thermal-zone = 2; - # hwmon-path" = "/sys/class/hwmon/hwmon2/temp1_input"; - critical-threshold = 80; - # format-critical = "{temperatureC}°C "; - format = "{temperatureC}°C "; - }; - "backlight" = { - # device = "acpi_video1"; - format = "{percent}% {icon}"; - states = [ 0 50 ]; - format-icons = [ "" "" ]; - }; - "battery" = mkIf cfg.enableLaptopBars { - states = { - good = 95; - warning = 30; - critical = 15; - }; - format = "{capacity}% {icon}"; - # format-good = ""; # An empty format will hide the module - # format-full = ""; - format-icons = [ "" "" "" "" "" ]; - }; - "battery#bat2" = mkIf cfg.enableLaptopBars { - bat = "BAT2"; - }; - "network" = { - # interface = wlp2s0 # (Optional) To force the use of this interface - format-wifi = "{essid} ({signalStrength}%) "; - format-ethernet = "{ifname}: {ipaddr}/{cidr} "; - format-disconnected = "Disconnected ⚠"; - interval = 7; - }; - "bluetooth" = { - format = " {status}"; - format-connected = " {device_alias}"; - format-connected-battery = " {device_alias} {device_battery_percentage}%"; - # format-device-preference= [ "device1", "device2" ], // preference list deciding the displayed devic; - tooltip-format = "{controller_alias}\t{controller_address}\n\n{num_connections} connected"; - tooltip-format-connected = "{controller_alias}\t{controller_address}\n\n{num_connections} connected\n\n{device_enumerate}"; - tooltip-format-enumerate-connected = "{device_alias}\t{device_address}"; - tooltip-format-enumerate-connected-battery = "{device_alias}\t{device_address}\t{device_battery_percentage}%"; - on-click = "${pkgs.blueman}/bin/blueman-manager"; - }; - "pulseaudio" = { - # scroll-step = 1; - format = "{volume}% {icon}"; - format-bluetooth = "{volume}% {icon}"; - format-muted = ""; - format-icons = { - headphones = ""; - handsfree = ""; - headset = ""; - phone = ""; - portable = ""; - car = ""; - default = [ "" "" ]; - }; - on-click = "${pkgs.pavucontrol}/bin/pavucontrol"; - }; - "mpd" = { - "format" = "{stateIcon} {consumeIcon}{randomIcon}{repeatIcon}{singleIcon}{artist} - {album} - {title} ({elapsedTime:%M:%S}/{totalTime:%M:%S}) 🎧"; - "format-disconnected" = "Disconnected 🎧"; - "format-stopped" = "{consumeIcon}{randomIcon}{repeatIcon}{singleIcon}Stopped 🎧"; - "interval" = 2; - "consume-icons" = { - "on" = " "; # Icon shows only when "consume" is on - }; - "random-icons" = { - "off" = " "; # Icon grayed out when "random" is off; - "on" = " "; - }; - "repeat-icons" = { - "on" = " "; - }; - "single-icons" = { - "on" = "1 "; - }; - "state-icons" = { - "paused" = ""; - "playing" = ""; - }; - "tooltip-format" = "MPD (connected)"; - "tooltip-format-disconnected" = "MPD (disconnected)"; - "on-click" = "${pkgs.mpc_cli}/bin/mpc toggle"; - "on-click-right" = "${pkgs.mpc_cli}/bin/mpc stop"; - "on-click-middle" = "${cfg.terminal} --class=kitty_ncmpcpp ${pkgs.ncmpcpp}/bin/ncmpcpp"; - }; - "custom/media" = { - "format" = "{icon}{}"; - "return-type" = "json"; - "format-icons" = { - "Playing" = " "; - "Paused" = " "; - }; - "max-length" = 80; - "exec" = "${playerctl} -a metadata --format '{\"text\": \"{{artist}} - {{markup_escape(title)}}\", \"tooltip\": \"{{playerName}} : {{markup_escape(title)}}\", \"alt\": \"{{status}}\", \"class\": \"{{status}}\"}' -F"; - "on-click" = "${playerctl} play-pause"; - }; - }; - }] ++ - cfg.waybar.extraSettings - ++ [ extraSettings ]); - in - mkIf cfg.enable { - enable = true; - systemd.enable = true; - systemd.target = "sway-session.target"; - settings = cfg.waybar.makeBars barWith; - style = '' - * { - border: none; - border-radius: 0; - font-family: monospace, 'Font Awesome 5', 'Symbols Nerd Font Mono', 'SFNS Display', Helvetica, Arial, sans-serif; - font-size: ${toString (cfg.fontSize * 1.1)}px; - min-height: 0; - } - - window#waybar { - background: rgba(43, 48, 59, 0.8); - border-bottom: 3px solid rgba(100, 114, 125, 0.5); - color: #ffffff; - } - - window#waybar.hidden { - opacity: 0.0; - } - /* https://github.com/Alexays/Waybar/wiki/FAQ#the-workspace-buttons-have-a-strange-hover-effect */ - #workspaces button { - padding: 0 5px; - background: transparent; - color: #ffffff; - border-bottom: 3px solid transparent; - } - - #workspaces button.focused { - background: #64727D; - border-bottom: 3px solid #ffffff; - } - - #workspaces button.urgent { - background-color: #eb4d4b; - } - - #window, #sway, #sway-window { - padding-left: 1em; - margin-bottom: 0.4em; - } - - #mode { - background: #64727D; - border-bottom: 3px solid #ffffff; - } - - /* #clock, #battery, #cpu, #memory, #temperature, #backlight, #network, #pulseaudio, #bluetooth, #custom-media, #tray, #mode, #idle_inhibitor, #mpd { */ - .modules-right > * > * { - margin: 0.2em 0 0.4em 0; - padding: 0.2em 0.5em; - border: 1px solid rgba(0, 0, 0, 0.25); - border-radius: 0.3em; - } - - .modules-right > *:not(:last-child) > * { - margin-right: 0.4em; - } - - #clock { - background-color: #64727D; - } - - #battery { - background-color: #ffffff; - color: #000000; - } - - #battery.charging { - color: #ffffff; - background-color: #26A65B; - } - - @keyframes blink { - to { - background-color: #ffffff; - color: #000000; - } - } - - #battery.critical:not(.charging) { - background: #f53c3c; - color: #ffffff; - animation-name: blink; - animation-duration: 0.5s; - animation-timing-function: linear; - animation-iteration-count: infinite; - animation-direction: alternate; - } - - #cpu { - background: #2ecc71; - color: #000000; - } - - #memory { - background: #9b59b6; - } - - #backlight { - background: #90b1b1; - } - - #network { - background: #2980b9; - } - - #network.disconnected { - background: #f53c3c; - } - - #pulseaudio { - background: #f1c40f; - color: #000000; - } - - #pulseaudio.muted { - background: #90b1b1; - } - - #bluetooth { - background: DarkSlateBlue; - color: white; - } - - #custom-media { - background: #66cc99; - color: #2a5c45; - } - - .custom-spotify { - background: #66cc99; - } - - .custom-vlc { - background: #ffa000; - } - - #temperature { - background: #f0932b; - } - - #temperature.critical { - background: #eb4d4b; - } - - #tray { - background-color: #2980b9; - } - - #idle_inhibitor { - background-color: #2d3436; - } - - #idle_inhibitor.activated { - background-color: #ecf0f1; - color: #2d3436; - } - - #mpd { - background-color: teal; - color: white; - } - '' + cfg.waybar.extraStyle; - }; config.home.packages = mkIf cfg.enable (with pkgs; [ # Needed for QT_QPA_PLATFORM kdePackages.qtwayland diff --git a/home/modules/programs/my-waybar.nix b/home/modules/programs/my-waybar.nix new file mode 100644 index 0000000..59bb9c4 --- /dev/null +++ b/home/modules/programs/my-waybar.nix @@ -0,0 +1,408 @@ +{ lib, config, pkgs, ... }: +let + cfg = config.programs.my-waybar; +in +{ + options.programs.my-waybar = { + enable = lib.mkEnableOption "custom configuration for waybar"; + fontSize = lib.mkOption { + type = lib.types.float; + description = "The default font size"; + }; + terminal = lib.mkOption { + type = lib.types.str; + description = "The command to the terminal emulator to be used"; + default = "${config.programs.kitty.package}/bin/kitty"; + }; + + enableLaptopBars = lib.mkOption { + type = lib.types.bool; + description = "Whether to enable laptop-specific bars (battery)"; + default = true; + }; + enableMpd = lib.mkOption { + type = lib.types.bool; + description = "Whether to enable mpd on waybar"; + default = false; + }; + + makeBars = lib.mkOption { + type = lib.types.raw; + description = "Create bars with the barWith function, return a list of bars"; + default = barWith: [ (barWith { }) ]; + }; + extraSettings = lib.mkOption { + type = lib.types.listOf lib.types.raw; + description = "Extra settings to be included with every default bar"; + default = [ ]; + }; + extraStyle = lib.mkOption { + type = lib.types.lines; + description = "Additional style for the default waybar"; + default = ""; + }; + }; + config.programs.waybar = + let + barWith = { showMedia ? true, showConnectivity ? true, extraSettings ? { }, ... }: lib.mkMerge ([{ + position = "top"; + modules-left = [ + "sway/workspaces" + "sway/mode" + "sway/window" + ]; + modules-center = [ + ]; + modules-right = + lib.optional showMedia (if cfg.enableMpd then "mpd" else "custom/media") + ++ [ + "tray" + "pulseaudio" + ] ++ lib.optionals showConnectivity [ + "bluetooth" + "network" + ] ++ [ + "cpu" + "memory" + "temperature" + ] ++ lib.optionals cfg.enableLaptopBars [ "battery" "battery#bat2" ] + ++ [ + "clock" + ]; + + modules = { + "sway/workspaces" = { + format = "{name}"; + }; + "sway/mode" = { + format = "{}"; + }; + "sway/window" = { + max-length = 70; + format = "{title}"; + "rewrite" = { + "(.*) — Mozilla Firefox" = "[🌎] $1"; + "(.*) - Mozilla Thunderbird" = "[📧] $1"; + "(.*) - Kakoune" = "[⌨️] $1"; + "(.*) - fish" = "[>_] $1"; + "(.*) - Discord" = "[🗨️] $1"; + # ArmCord thing + "• Discord \\| (.*)" = "[🗨️] $1"; + "\\((\\d+)\\) Discord \\| (.*)" = "[🗨️] {$1} $2"; + }; + }; + "tray" = { + icon-size = 21; + spacing = 10; + }; + "clock" = { + # format = "{:📅 %Y-%m-%d | 🕰️ %H:%M [%Z]}"; + format = "📅 {0:%Y-%m-%d} |️ 🕰️ {0:%H:%M [%Z]}"; + tooltip-format = "\n{calendar}"; + timezones = [ + "Europe/Zurich" + "America/Toronto" + "Asia/Tokyo" + "Asia/Ho_Chi_Minh" + ]; + calendar = { + mode = "year"; + mode-mon-col = 3; + weeks-pos = "right"; + on-scroll = 1; + on-click-right = "mode"; + format = { + months = "{}"; + days = "{}"; + weeks = "W{}"; + weekdays = "日 月 火 水 木 金 土"; # See https://github.com/Alexays/Waybar/issues/3132 + today = "{}"; + }; + }; + actions = { + on-click-middle = "mode"; + on-click-right = "tz_up"; + on-scroll-up = "shift_up"; + on-scroll-down = "shift_down"; + }; + }; + "cpu" = { + format = "{usage}% "; + }; + "memory" = { + format = "{}% "; + }; + "temperature" = { + # thermal-zone = 2; + # hwmon-path" = "/sys/class/hwmon/hwmon2/temp1_input"; + critical-threshold = 80; + # format-critical = "{temperatureC}°C "; + format = "{temperatureC}°C "; + }; + "backlight" = { + # device = "acpi_video1"; + format = "{percent}% {icon}"; + states = [ 0 50 ]; + format-icons = [ "" "" ]; + }; + "battery" = lib.mkIf cfg.enableLaptopBars { + states = { + good = 95; + warning = 30; + critical = 15; + }; + format = "{capacity}% {icon}"; + # format-good = ""; # An empty format will hide the module + # format-full = ""; + format-icons = [ "" "" "" "" "" ]; + }; + "battery#bat2" = lib.mkIf cfg.enableLaptopBars { + bat = "BAT2"; + }; + "network" = { + # interface = wlp2s0 # (Optional) To force the use of this interface + format-wifi = "{essid} ({signalStrength}%) "; + format-ethernet = "{ifname}: {ipaddr}/{cidr} "; + format-disconnected = "Disconnected ⚠"; + interval = 7; + }; + "bluetooth" = { + format = " {status}"; + format-connected = " {device_alias}"; + format-connected-battery = " {device_alias} {device_battery_percentage}%"; + # format-device-preference= [ "device1", "device2" ], // preference list deciding the displayed devic; + tooltip-format = "{controller_alias}\t{controller_address}\n\n{num_connections} connected"; + tooltip-format-connected = "{controller_alias}\t{controller_address}\n\n{num_connections} connected\n\n{device_enumerate}"; + tooltip-format-enumerate-connected = "{device_alias}\t{device_address}"; + tooltip-format-enumerate-connected-battery = "{device_alias}\t{device_address}\t{device_battery_percentage}%"; + on-click = "${pkgs.blueman}/bin/blueman-manager"; + }; + "pulseaudio" = { + # scroll-step = 1; + format = "{volume}% {icon}"; + format-bluetooth = "{volume}% {icon}"; + format-muted = ""; + format-icons = { + headphones = ""; + handsfree = ""; + headset = ""; + phone = ""; + portable = ""; + car = ""; + default = [ "" "" ]; + }; + on-click = "${pkgs.pavucontrol}/bin/pavucontrol"; + }; + "mpd" = { + "format" = "{stateIcon} {consumeIcon}{randomIcon}{repeatIcon}{singleIcon}{artist} - {album} - {title} ({elapsedTime:%M:%S}/{totalTime:%M:%S}) 🎧"; + "format-disconnected" = "Disconnected 🎧"; + "format-stopped" = "{consumeIcon}{randomIcon}{repeatIcon}{singleIcon}Stopped 🎧"; + "interval" = 2; + "consume-icons" = { + "on" = " "; # Icon shows only when "consume" is on + }; + "random-icons" = { + "off" = " "; # Icon grayed out when "random" is off; + "on" = " "; + }; + "repeat-icons" = { + "on" = " "; + }; + "single-icons" = { + "on" = "1 "; + }; + "state-icons" = { + "paused" = ""; + "playing" = ""; + }; + "tooltip-format" = "MPD (connected)"; + "tooltip-format-disconnected" = "MPD (disconnected)"; + "on-click" = "${pkgs.mpc_cli}/bin/mpc toggle"; + "on-click-right" = "${pkgs.mpc_cli}/bin/mpc stop"; + "on-click-middle" = "${cfg.terminal} --class=kitty_ncmpcpp ${pkgs.ncmpcpp}/bin/ncmpcpp"; + }; + "custom/media" = { + "format" = "{icon}{}"; + "return-type" = "json"; + "format-icons" = { + "Playing" = " "; + "Paused" = " "; + }; + "max-length" = 80; + "exec" = "${lib.getExe pkgs.playerctl} -a metadata --format '{\"text\": \"{{artist}} - {{markup_escape(title)}}\", \"tooltip\": \"{{playerName}} : {{markup_escape(title)}}\", \"alt\": \"{{status}}\", \"class\": \"{{status}}\"}' -F"; + "on-click" = "${lib.getExe pkgs.playerctl} play-pause"; + }; + }; + }] ++ + cfg.extraSettings + ++ [ extraSettings ]); + in + lib.mkIf cfg.enable { + enable = true; + systemd.enable = true; + systemd.target = "sway-session.target"; + settings = cfg.makeBars barWith; + style = '' + * { + border: none; + border-radius: 0; + font-family: monospace, 'Font Awesome 5', 'Symbols Nerd Font Mono', 'SFNS Display', Helvetica, Arial, sans-serif; + font-size: ${toString (cfg.fontSize * 1.1)}px; + min-height: 0; + } + + window#waybar { + background: rgba(43, 48, 59, 0.8); + border-bottom: 3px solid rgba(100, 114, 125, 0.5); + color: #ffffff; + } + + window#waybar.hidden { + opacity: 0.0; + } + /* https://github.com/Alexays/Waybar/wiki/FAQ#the-workspace-buttons-have-a-strange-hover-effect */ + #workspaces button { + padding: 0 5px; + background: transparent; + color: #ffffff; + border-bottom: 3px solid transparent; + } + + #workspaces button.focused { + background: #64727D; + border-bottom: 3px solid #ffffff; + } + + #workspaces button.urgent { + background-color: #eb4d4b; + } + + #window, #sway, #sway-window { + padding-left: 1em; + margin-bottom: 0.4em; + } + + #mode { + background: #64727D; + border-bottom: 3px solid #ffffff; + } + + /* #clock, #battery, #cpu, #memory, #temperature, #backlight, #network, #pulseaudio, #bluetooth, #custom-media, #tray, #mode, #idle_inhibitor, #mpd { */ + .modules-right > * > * { + margin: 0.2em 0 0.4em 0; + padding: 0.2em 0.5em; + border: 1px solid rgba(0, 0, 0, 0.25); + border-radius: 0.3em; + } + + .modules-right > *:not(:last-child) > * { + margin-right: 0.4em; + } + + #clock { + background-color: #64727D; + } + + #battery { + background-color: #ffffff; + color: #000000; + } + + #battery.charging { + color: #ffffff; + background-color: #26A65B; + } + + @keyframes blink { + to { + background-color: #ffffff; + color: #000000; + } + } + + #battery.critical:not(.charging) { + background: #f53c3c; + color: #ffffff; + animation-name: blink; + animation-duration: 0.5s; + animation-timing-function: linear; + animation-iteration-count: infinite; + animation-direction: alternate; + } + + #cpu { + background: #2ecc71; + color: #000000; + } + + #memory { + background: #9b59b6; + } + + #backlight { + background: #90b1b1; + } + + #network { + background: #2980b9; + } + + #network.disconnected { + background: #f53c3c; + } + + #pulseaudio { + background: #f1c40f; + color: #000000; + } + + #pulseaudio.muted { + background: #90b1b1; + } + + #bluetooth { + background: DarkSlateBlue; + color: white; + } + + #custom-media { + background: #66cc99; + color: #2a5c45; + } + + .custom-spotify { + background: #66cc99; + } + + .custom-vlc { + background: #ffa000; + } + + #temperature { + background: #f0932b; + } + + #temperature.critical { + background: #eb4d4b; + } + + #tray { + background-color: #2980b9; + } + + #idle_inhibitor { + background-color: #2d3436; + } + + #idle_inhibitor.activated { + background-color: #ecf0f1; + color: #2d3436; + } + + #mpd { + background-color: teal; + color: white; + } + '' + cfg.extraStyle; + }; +} diff --git a/home/nki-framework.nix b/home/nki-framework.nix index 02ab99b..b44533a 100644 --- a/home/nki-framework.nix +++ b/home/nki-framework.nix @@ -48,7 +48,7 @@ tap = "enabled"; }; }; - programs.my-sway.waybar.extraSettings = + programs.my-waybar.extraSettings = let change-mode = pkgs.writeScript "change-mode" '' #!/usr/bin/env ${lib.getExe pkgs.fish} From 0a0e396ddf97f28487b08c8253a937dfaf578589 Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Wed, 15 Jan 2025 21:42:55 +0100 Subject: [PATCH 13/24] Factor out default terminal and web browser --- home/kagami-pc-home.nix | 8 +--- home/modules/linux/graphical/default.nix | 46 ++++++++++++++++------ home/modules/programs/my-kitty/default.nix | 9 +++++ home/modules/programs/my-sway/default.nix | 5 ++- home/nki-framework.nix | 4 +- home/nki-x1c1.nix | 5 +-- 6 files changed, 50 insertions(+), 27 deletions(-) diff --git a/home/kagami-pc-home.nix b/home/kagami-pc-home.nix index 539cfe9..ce12a7d 100644 --- a/home/kagami-pc-home.nix +++ b/home/kagami-pc-home.nix @@ -37,12 +37,8 @@ # Enable X11 configuration linux.graphical.type = "wayland"; linux.graphical.wallpaper = ./images/pixiv_18776904.png; - linux.graphical.startup = with pkgs; [ - zen-browser-bin - thunderbird - vesktop - ]; - linux.graphical.defaults.webBrowser = "zen.desktop"; + linux.graphical.defaults.webBrowser.package = pkgs.zen-browser-bin; + linux.graphical.defaults.webBrowser.desktopFile = "zen.desktop"; programs.my-sway.enable = true; programs.my-sway.fontSize = 15.0; programs.my-sway.enableLaptop = true; diff --git a/home/modules/linux/graphical/default.nix b/home/modules/linux/graphical/default.nix index 499088a..238f7fe 100644 --- a/home/modules/linux/graphical/default.nix +++ b/home/modules/linux/graphical/default.nix @@ -17,6 +17,24 @@ let echo $wifi_output end ''; + + mkPackageWithDesktopOption = opts: mkOption ({ + type = types.submodule { + options = { + package = mkOption { + type = types.package; + description = "The package for " + description; + }; + desktopFile = mkOption { + type = types.nullOr types.str; + default = null; + description = "The desktop file name for " + description + ", defaults to [packagename].desktop"; + }; + }; + }; + } // opts); + + desktopFileOf = cfg: if cfg.desktopFile == null then "${cfg.package}/share/applications/${cfg.package.pname}.desktop" else cfg.desktopFile; in { imports = [ ./x11.nix ./wayland.nix ./alacritty.nix ]; @@ -35,21 +53,23 @@ in type = types.listOf types.package; description = "List of packages to include in ~/.config/autostart"; default = with pkgs; [ - librewolf + cfg.defaults.webBrowser.package thunderbird vesktop ]; }; - defaults.webBrowser = mkOption { - type = types.str; - default = "librewolf.desktop"; - description = "Desktop file of the default web browser"; + defaults = { + webBrowser = mkPackageWithDesktopOption { description = "default web browser"; }; + terminal = mkPackageWithDesktopOption { description = "default terminal"; default.package = pkgs.kitty; }; }; }; config = mkIf (cfg.type != null) { # Packages home.packages = (with pkgs; [ + cfg.defaults.webBrowser.package + cfg.defaults.terminal.package + ## GUI stuff evince # PDF reader gparted @@ -150,14 +170,14 @@ in "application/x-extension-rss" = [ "thunderbird.desktop" ]; # Default web browser stuff - "text/html" = [ cfg.defaults.webBrowser ]; - "x-scheme-handler/about" = [ cfg.defaults.webBrowser ]; - "x-scheme-handler/unknown" = [ cfg.defaults.webBrowser ]; - "x-scheme-handler/http" = [ cfg.defaults.webBrowser ]; - "x-scheme-handler/https" = [ cfg.defaults.webBrowser ]; - "x-scheme-handler/ftp" = [ cfg.defaults.webBrowser ]; - "x-scheme-handler/ftps" = [ cfg.defaults.webBrowser ]; - "x-scheme-handler/file" = [ cfg.defaults.webBrowser ]; + "text/html" = [ (desktopFileOf cfg.defaults.webBrowser) ]; + "x-scheme-handler/about" = [ (desktopFileOf cfg.defaults.webBrowser) ]; + "x-scheme-handler/unknown" = [ (desktopFileOf cfg.defaults.webBrowser) ]; + "x-scheme-handler/http" = [ (desktopFileOf cfg.defaults.webBrowser) ]; + "x-scheme-handler/https" = [ (desktopFileOf cfg.defaults.webBrowser) ]; + "x-scheme-handler/ftp" = [ (desktopFileOf cfg.defaults.webBrowser) ]; + "x-scheme-handler/ftps" = [ (desktopFileOf cfg.defaults.webBrowser) ]; + "x-scheme-handler/file" = [ (desktopFileOf cfg.defaults.webBrowser) ]; # Torrent "application/x-bittorrent" = [ "deluge.desktop" ]; diff --git a/home/modules/programs/my-kitty/default.nix b/home/modules/programs/my-kitty/default.nix index a1c03c0..fe82ff0 100644 --- a/home/modules/programs/my-kitty/default.nix +++ b/home/modules/programs/my-kitty/default.nix @@ -19,6 +19,11 @@ with lib; options.nki.programs.kitty = { enable = mkEnableOption "Enable kitty"; + setDefault = mkOption { + type = types.bool; + description = "Set kitty as default terminal"; + default = true; + }; package = mkOption { type = types.package; @@ -51,6 +56,10 @@ with lib; }; }; + config.linux.graphical = mkIf (cfg.enable && cfg.setDefault) { + defaults.terminal.package = cfg.package; + }; + config.programs.kitty = mkIf cfg.enable { enable = true; diff --git a/home/modules/programs/my-sway/default.nix b/home/modules/programs/my-sway/default.nix index 138dcab..36a224f 100644 --- a/home/modules/programs/my-sway/default.nix +++ b/home/modules/programs/my-sway/default.nix @@ -68,12 +68,12 @@ in terminal = mkOption { type = types.str; description = "The command to the terminal emulator to be used"; - default = "${config.programs.kitty.package}/bin/kitty"; + default = lib.getExe config.linux.graphical.defaults.terminal.package; }; browser = mkOption { type = types.str; description = "The command for the browser"; - default = "${pkgs.firefox-wayland}/bin/firefox"; + default = lib.getExe config.linux.graphical.defaults.webBrowser.package; }; enableLaptop = lib.mkOption { @@ -276,6 +276,7 @@ in "${builtins.elemAt workspaces 0}" = [ { app_id = "^firefox$"; } { app_id = "^librewolf$"; } + { app_id = "^zen$"; } ]; "${builtins.elemAt workspaces 1}" = [ { class = "^((d|D)iscord|((A|a)rm(c|C)ord))$"; } diff --git a/home/nki-framework.nix b/home/nki-framework.nix index b44533a..516c33f 100644 --- a/home/nki-framework.nix +++ b/home/nki-framework.nix @@ -29,12 +29,10 @@ # Graphical set up linux.graphical.type = "wayland"; linux.graphical.wallpaper = ./images/wallpaper_0.png; - linux.graphical.defaults.webBrowser = "librewolf.desktop"; + linux.graphical.defaults.webBrowser.package = pkgs.librewolf; # Enable sway programs.my-sway.enable = true; programs.my-sway.fontSize = 14.0; - programs.my-sway.terminal = "${config.programs.kitty.package}/bin/kitty"; - programs.my-sway.browser = "librewolf"; wayland.windowManager.sway.config = { # Keyboard support input."*".xkb_layout = "jp"; diff --git a/home/nki-x1c1.nix b/home/nki-x1c1.nix index dbad824..ce34779 100644 --- a/home/nki-x1c1.nix +++ b/home/nki-x1c1.nix @@ -30,12 +30,11 @@ linux.graphical.type = "wayland"; linux.graphical.wallpaper = ./images/wallpaper_0.png; linux.graphical.startup = with pkgs; [ zen-browser-bin thunderbird vesktop slack ]; - linux.graphical.defaults.webBrowser = "zen.desktop"; + linux.graphical.defaults.webBrowser.package = pkgs.zen-browser-bin; + linux.graphical.defaults.webBrowser.desktopFile = "zen.desktop"; # Enable sway programs.my-sway.enable = true; programs.my-sway.fontSize = 14.0; - programs.my-sway.terminal = "${config.programs.kitty.package}/bin/kitty"; - programs.my-sway.browser = "librewolf"; wayland.windowManager.sway.config = { # Keyboard support input."*".xkb_layout = "jp"; From 79c213bd64bbe670c4955b85665e7dafd8507f27 Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Wed, 15 Jan 2025 21:49:55 +0100 Subject: [PATCH 14/24] Use default value instead of passing for wallpaper --- home/modules/linux/graphical/wayland.nix | 3 --- home/modules/programs/my-sway/default.nix | 2 +- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/home/modules/linux/graphical/wayland.nix b/home/modules/linux/graphical/wayland.nix index 2763c99..5996652 100644 --- a/home/modules/linux/graphical/wayland.nix +++ b/home/modules/linux/graphical/wayland.nix @@ -119,9 +119,6 @@ with lib; # settings.experimental.per_monitor_dpi = "true"; # }; - - # Forward wallpaper settings to sway - programs.my-sway.wallpaper = config.linux.graphical.wallpaper; }; } diff --git a/home/modules/programs/my-sway/default.nix b/home/modules/programs/my-sway/default.nix index 36a224f..093f6e5 100644 --- a/home/modules/programs/my-sway/default.nix +++ b/home/modules/programs/my-sway/default.nix @@ -63,7 +63,7 @@ in wallpaper = mkOption { type = types.oneOf [ types.path types.str ]; description = "Path to the wallpaper to be used"; - default = ""; + default = config.linux.graphical.wallpaper; }; terminal = mkOption { type = types.str; From 704f1f1c79e193f82abda8e9e7cb89a766566ae8 Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Thu, 16 Jan 2025 04:23:20 +0100 Subject: [PATCH 15/24] Generalize monitors so they work across WMs --- home/kagami-pc-home.nix | 19 ++-------------- home/modules/linux/graphical/wayland.nix | 2 +- home/modules/monitors.nix | 29 +++++++++++++++++------- home/modules/programs/my-waybar.nix | 2 +- 4 files changed, 25 insertions(+), 27 deletions(-) diff --git a/home/kagami-pc-home.nix b/home/kagami-pc-home.nix index ce12a7d..7eac50d 100644 --- a/home/kagami-pc-home.nix +++ b/home/kagami-pc-home.nix @@ -47,28 +47,13 @@ wayland.windowManager.sway.config.input."type:keyboard".xkb_layout = "jp"; wayland.windowManager.sway.config.input."type:pointer".accel_profile = "flat"; # 144hz adaptive refresh ON! - wayland.windowManager.sway.config.output = - let - scale = 1.5; - top_x = builtins.ceil (3840 / scale); - top_y = 0; - in - with config.common.monitors; { - ${home_4k.name} = { - scale = toString scale; - position = "0 0"; - }; - ${home_1440.name} = { - position = "${toString top_x} ${toString top_y}"; - }; - }; nki.programs.kitty.enable = true; nki.programs.kitty.fontSize = 14; programs.my-waybar.makeBars = with config.common.monitors; barWith: [ # For primary - (barWith { extraSettings = { output = [ home_4k.name ]; }; }) + (barWith { extraSettings = { output = [ home_4k.meta.connection ]; }; }) # For secondary, hide mpd - (barWith { showMedia = false; showConnectivity = false; extraSettings = { output = [ home_1440.name ]; }; }) + (barWith { showMedia = false; showConnectivity = false; extraSettings = { output = [ home_1440.meta.connection ]; }; }) ]; # Yellow light! diff --git a/home/modules/linux/graphical/wayland.nix b/home/modules/linux/graphical/wayland.nix index 5996652..a0a0b27 100644 --- a/home/modules/linux/graphical/wayland.nix +++ b/home/modules/linux/graphical/wayland.nix @@ -11,7 +11,7 @@ let style = ./swaync.css; }; systemd.user.services.swaync.Install.WantedBy = lib.mkForce [ "sway-session.target" ]; - systemd.user.services.swaync.Unit.PartOf = lib.mkForce [ "sway-session.target" ]; + systemd.user.services.swaync.Unit.PartOf = lib.mkForce [ "graphical-session.target" ]; programs.my-waybar = { extraSettings = [{ diff --git a/home/modules/monitors.nix b/home/modules/monitors.nix index 70b7013..1b53096 100644 --- a/home/modules/monitors.nix +++ b/home/modules/monitors.nix @@ -5,32 +5,41 @@ let # Internal "framework" = { name = "BOE 0x0BCA Unknown"; - mode = "2256x1504@60Hz"; + meta.mode = { width = 2256; height = 1504; refresh = 60.0; }; scale = 1.25; }; # External ## Work @ EPFL "work" = { name = "LG Electronics LG ULTRAFINE 301MAXSGHD10"; - mode = "3840x2160@60Hz"; + meta.mode = { width = 3840; height = 2160; refresh = 60.0; }; scale = 1.25; }; "home_4k" = { name = "AOC U28G2G6B PPYP2JA000013"; - mode = "3840x2160@60Hz"; scale = 1.5; adaptive_sync = "on"; - # render_bit_depth = "10"; + meta = { + connection = "DP-2"; + mode = { width = 3840; height = 2160; refresh = 60.0; }; + fixedPosition = { x = 0; y = 0; }; + niriName = "PNP(AOC) U28G2G6B PPYP2JA000013"; + }; }; "home_1440" = { name = "AOC Q27G2G3R3B VXJP6HA000442"; - mode = "2560x1440@165Hz"; adaptive_sync = "on"; + meta = { + connection = "DP-3"; + mode = { width = 2560; height = 1440; refresh = 165.0; }; + fixedPosition = { x = 2560; y = 0; }; + niriName = "PNP(AOC) Q27G2G3R3B VXJP6HA000442"; + }; }; "viewsonic_1080" = { name = "ViewSonic Corporation XG2402 SERIES V4K182501054"; - mode = "1920x1080@144Hz"; + meta.mode = { width = 1920; height = 1080; refresh = 144.0; }; adaptive_sync = "on"; }; @@ -38,9 +47,13 @@ let eachMonitor = _name: monitor: { name = monitor.name; - value = builtins.removeAttrs monitor [ "scale" "name" ] // (if monitor ? scale then { + value = builtins.removeAttrs monitor [ "scale" "name" "meta" ] // (lib.optionalAttrs (monitor ? scale) { scale = toString monitor.scale; - } else { }); + }) // { + mode = with monitor.meta.mode; "${toString width}x${toString height}@${toString refresh}Hz"; + } // (lib.optionalAttrs (monitor.meta ? fixedPosition) { + position = with monitor.meta.fixedPosition; "${toString x} ${toString y}"; + }); }; in { diff --git a/home/modules/programs/my-waybar.nix b/home/modules/programs/my-waybar.nix index 59bb9c4..f9ffe30 100644 --- a/home/modules/programs/my-waybar.nix +++ b/home/modules/programs/my-waybar.nix @@ -240,7 +240,7 @@ in lib.mkIf cfg.enable { enable = true; systemd.enable = true; - systemd.target = "sway-session.target"; + systemd.target = "graphical-session.target"; settings = cfg.makeBars barWith; style = '' * { From 61382f4d32a56e00db34d1cefa2c0947be31be6c Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Thu, 16 Jan 2025 04:23:55 +0100 Subject: [PATCH 16/24] Add niri module - An overridden `niri.service` is provided, so that systemd does not take over autostart and try to start things *before* we have an XWayland server running. - Somehow `wlsunset` is still not working, might need some investigation into why. --- home/common.nix | 1 + home/fish/fish.nix | 5 + home/kagami-pc-home.nix | 1 + home/modules/programs/my-kitty/default.nix | 2 +- home/modules/programs/my-niri.nix | 328 +++++++++++++++++++++ home/modules/programs/my-waybar.nix | 16 + modules/common/linux/default.nix | 28 +- 7 files changed, 379 insertions(+), 2 deletions(-) create mode 100644 home/modules/programs/my-niri.nix diff --git a/home/common.nix b/home/common.nix index 0768e21..a8d6035 100644 --- a/home/common.nix +++ b/home/common.nix @@ -7,6 +7,7 @@ ./modules/programs/my-broot.nix ./modules/programs/my-waybar.nix ./modules/programs/my-sway + ./modules/programs/my-niri.nix ./modules/programs/my-kitty ./modules/programs/openconnect-epfl.nix ./common-linux.nix diff --git a/home/fish/fish.nix b/home/fish/fish.nix index 23a49cd..58babb5 100644 --- a/home/fish/fish.nix +++ b/home/fish/fish.nix @@ -13,6 +13,9 @@ let if which sway &>/dev/null set -a CHOICES "sway" end + if which niri-session &>/dev/null + set -a CHOICES "Niri" + end if which startplasma-wayland &>/dev/null set -a CHOICES "KDE Plasma" end @@ -22,6 +25,8 @@ let case "sway" systemctl --user unset-environment NIXOS_OZONE_WL exec sway + case "Niri" + exec niri-session case "KDE Plasma" exec ${pkgs.kdePackages.plasma-workspace}/libexec/plasma-dbus-run-session-if-needed startplasma-wayland case '*' diff --git a/home/kagami-pc-home.nix b/home/kagami-pc-home.nix index 7eac50d..659c13d 100644 --- a/home/kagami-pc-home.nix +++ b/home/kagami-pc-home.nix @@ -39,6 +39,7 @@ linux.graphical.wallpaper = ./images/pixiv_18776904.png; linux.graphical.defaults.webBrowser.package = pkgs.zen-browser-bin; linux.graphical.defaults.webBrowser.desktopFile = "zen.desktop"; + programs.my-niri.enable = true; programs.my-sway.enable = true; programs.my-sway.fontSize = 15.0; programs.my-sway.enableLaptop = true; diff --git a/home/modules/programs/my-kitty/default.nix b/home/modules/programs/my-kitty/default.nix index fe82ff0..45801dd 100644 --- a/home/modules/programs/my-kitty/default.nix +++ b/home/modules/programs/my-kitty/default.nix @@ -74,7 +74,7 @@ with lib; # Background color and transparency background = if isNull cfg.background then { - background_opacity = "0.85"; + background_opacity = "0.93"; dynamic_background_opacity = true; } else { background_image = "${cfg.background}"; diff --git a/home/modules/programs/my-niri.nix b/home/modules/programs/my-niri.nix new file mode 100644 index 0000000..d6311b2 --- /dev/null +++ b/home/modules/programs/my-niri.nix @@ -0,0 +1,328 @@ +{ config, osConfig, lib, pkgs, ... }: +let + cfg = config.programs.my-niri; + + sh = config.lib.niri.actions.spawn "sh" "-c"; + playerctl = lib.getExe pkgs.playerctl; + amixer = lib.getExe' pkgs.alsa-utils "amixer"; + brightnessctl = lib.getExe pkgs.brightnessctl; + app-menu = "${pkgs.dmenu}/bin/dmenu_path | ${pkgs.bemenu}/bin/bemenu | ${pkgs.findutils}/bin/xargs swaymsg exec --"; + + wallpaper = config.linux.graphical.wallpaper; + + workspaces = { + "01" = { name = "🌏 web"; }; + "02" = { name = "💬 chat"; }; + "03" = { name = "⚙️ code"; }; + "04" = { name = "🎶 music"; }; + "05" = { name = "🔧 extra"; }; + "06" = { name = "🧰 6"; }; + "07" = { name = "🔩 7"; }; + "08" = { name = "🛠️ 8"; }; + "09" = { name = "🔨 9"; }; + "10" = { name = "🎲 misc"; }; + "99" = { name = "📧 Email"; }; + }; + + xwayland-display = ":12"; + +in +{ + options.programs.my-niri = { + enable = lib.mkEnableOption "My own niri configuration"; + + enableLaptop = lib.mkOption { + type = lib.types.bool; + default = false; + description = "Enable laptop options"; + }; + + lock-command = lib.mkOption { + type = lib.types.listOf lib.types.str; + description = "The command to lock the screen"; + default = [ "${pkgs.swaylock}/bin/swaylock" ] + ++ (if wallpaper == "" then [ "" ] else [ "-i" "${wallpaper}" "-s" "fill" ]) + ++ [ "-l" "-k" ]; + }; + }; + + config = lib.mkIf cfg.enable { + programs.niri.settings = { + environment = { + QT_QPA_PLATFORM = "wayland"; + QT_WAYLAND_DISABLE_WINDOWDECORATION = "1"; + QT_IM_MODULE = "fcitx"; + GTK_IM_MODULE = "fcitx"; # Til text-input is merged + # export NIXOS_OZONE_WL=1 # Until text-input is merged + DISPLAY = xwayland-display; + } // lib.optionalAttrs osConfig.services.desktopManager.plasma6.enable { + XDG_MENU_PREFIX = "plasma-"; + }; + input.keyboard.xkb = { layout = "jp"; }; + input.touchpad = lib.mkIf cfg.enableLaptop { + tap = true; + dwt = true; + natural-scroll = true; + middle-emulation = true; + }; + input.mouse = { + accel-profile = "flat"; + }; + input.warp-mouse-to-focus = true; + input.focus-follows-mouse = { + enable = true; + max-scroll-amount = "0%"; + }; + + outputs = + let + eachMonitor = _: monitor: { + name = monitor.meta.niriName or monitor.name; # Niri might not find the monitor by name + value = { + mode = monitor.meta.mode; + position = monitor.meta.fixedPosition or null; + scale = monitor.scale or 1; + variable-refresh-rate = (monitor.adaptive_sync or "off") == "on"; + }; + }; + in + lib.mapAttrs' eachMonitor config.common.monitors; + + spawn-at-startup = [ + # Wallpaper + { command = [ (lib.getExe pkgs.swaybg) "-i" "${wallpaper}" "-m" "fill" ]; } + # IME + { command = [ "fcitx5" ]; } + # XWayland + { command = [ (lib.getExe pkgs.xwayland-satellite) xwayland-display ]; } + # Waybar + { command = [ "systemctl" "--user" "start" "swaync.service" ]; } + { command = [ "systemctl" "--user" "start" "xdg-desktop-portal-gtk.service" "xdg-desktop-portal.service" ]; } + { command = [ "systemctl" "--user" "reset-failed" "waybar.service" "wlsunset.service" ]; } + # Startup + { command = [ (lib.getExe pkgs.dex) "-ae" "niri" ]; } + ]; + + layout = { + gaps = 16; + preset-column-widths = [ + { proportion = 1. / 3.; } + { proportion = 1. / 2.; } + { proportion = 2. / 3.; } + ]; + default-column-width.proportion = 1. / 2.; + + focus-ring = { + width = 4; + active.gradient = { from = "#00447AFF"; to = "#71C4FFAA"; angle = 45; }; + inactive.color = "#505050"; + }; + border.enable = false; + struts = let v = 8; in { left = v; right = v; bottom = v; top = v; }; + }; + + prefer-no-csd = true; + + inherit workspaces; + + window-rules = [ + # Rounded Corners + { + geometry-corner-radius = let v = 8.0; in { bottom-left = v; bottom-right = v; top-left = v; top-right = v; }; + clip-to-geometry = true; + } + # Workspace assignments + { + open-on-workspace = workspaces."01".name; + open-maximized = true; + matches = [ + { at-startup = true; app-id = "^firefox$"; } + { at-startup = true; app-id = "^librewolf$"; } + { at-startup = true; app-id = "^zen$"; } + ]; + } + { + open-on-workspace = workspaces."02".name; + open-maximized = true; + matches = [ + { title = "^((d|D)iscord|((A|a)rm(c|C)ord))$"; } + { title = "VencordDesktop"; } + { app-id = "VencordDesktop"; } + { title = "vesktop"; } + { app-id = "vesktop"; } + + { title = "Slack"; } + ]; + } + { + open-on-workspace = workspaces."99".name; + open-maximized = true; + matches = [ + { app-id = "thunderbird"; } + { app-id = "evolution"; } + ]; + } + # Floating + { + open-floating = true; + matches = [ + { app-id = ".*float.*"; } + { app-id = "org\\.freedesktop\\.impl\\.portal\\.desktop\\..*"; } + { title = ".*float.*"; } + { title = "Extension: .*Bitwarden.*"; } + { app-id = "Rofi"; } + ]; + } + + # Kitty dimming + { + matches = [{ app-id = "kitty"; }]; + excludes = [{ is-focused = true; }]; + opacity = 0.95; + } + ]; + + layer-rules = [ + { + matches = [{ namespace = "^swaync-.*"; }]; + block-out-from = "screen-capture"; + } + ]; + + binds = with config.lib.niri.actions; { + # Mod-Shift-/, which is usually the same as Mod-?, + # shows a list of important hotkeys. + "Mod+Shift+Slash".action = show-hotkey-overlay; + + # Some basic spawns + "Mod+Return".action = spawn (lib.getExe config.linux.graphical.defaults.terminal.package); + "Mod+Space".action = spawn (lib.getExe pkgs.rofi) "-show" "drun"; + "Mod+R".action = sh app-menu; + "Mod+Semicolon".action = spawn cfg.lock-command; + + # Audio and Volume + "XF86AudioPrev" = { action = spawn playerctl "previous"; allow-when-locked = true; }; + "XF86AudioPlay" = { action = spawn playerctl "play-pause"; allow-when-locked = true; }; + "Shift+XF86AudioPlay" = { action = spawn playerctl "stop"; allow-when-locked = true; }; + "XF86AudioNext" = { action = spawn playerctl "next"; allow-when-locked = true; }; + "XF86AudioRecord" = { action = spawn amixer "-q" "set" "Capture" "toggle"; allow-when-locked = true; }; + "XF86AudioMute" = { action = spawn amixer "-q" "set" "Master" "toggle"; allow-when-locked = true; }; + "XF86AudioLowerVolume" = { action = spawn amixer "-q" "set" "Master" "3%-"; allow-when-locked = true; }; + "XF86AudioRaiseVolume" = { action = spawn amixer "-q" "set" "Master" "3%+"; allow-when-locked = true; }; + + # Backlight + "XF86MonBrightnessDown".action = spawn brightnessctl "s" "10%-"; + "XF86MonBrightnessUp".action = spawn brightnessctl "s" "10%+"; + "Shift+XF86MonBrightnessDown".action = spawn brightnessctl "-d" "kbd_backlight" "s" "25%-"; + "Shift+XF86MonBrightnessUp".action = spawn brightnessctl "-d" "kbd_backlight" "s" "25%+"; + + "Mod+Shift+Q".action = close-window; + + "Mod+Left".action = focus-column-or-monitor-left; + "Mod+Right".action = focus-column-or-monitor-right; + "Mod+Up".action = focus-window-or-workspace-up; + "Mod+Down".action = focus-window-or-workspace-down; + "Mod+H".action = focus-column-or-monitor-left; + "Mod+L".action = focus-column-or-monitor-right; + "Mod+K".action = focus-window-or-workspace-up; + "Mod+J".action = focus-window-or-workspace-down; + + "Mod+Shift+Left".action = move-column-left-or-to-monitor-left; + "Mod+Shift+Right".action = move-column-right-or-to-monitor-right; + "Mod+Shift+Up".action = move-window-up-or-to-workspace-up; + "Mod+Shift+Down".action = move-window-down-or-to-workspace-down; + "Mod+Shift+H".action = move-column-left-or-to-monitor-left; + "Mod+Shift+L".action = move-column-right-or-to-monitor-right; + "Mod+Shift+K".action = move-window-up-or-to-workspace-up; + "Mod+Shift+J".action = move-window-down-or-to-workspace-down; + + "Mod+Bracketleft".action = focus-column-first; + "Mod+Bracketright".action = focus-column-last; + "Mod+Shift+Bracketleft".action = move-column-to-first; + "Mod+Shift+Bracketright".action = move-column-to-last; + + # For compat with my current sway + "Mod+Ctrl+H".action = move-workspace-to-monitor-left; + "Mod+Ctrl+L".action = move-workspace-to-monitor-right; + + "Mod+I".action = focus-workspace-down; + "Mod+O".action = focus-workspace-up; + "Mod+Shift+I".action = move-column-to-workspace-down; + "Mod+Shift+O".action = move-column-to-workspace-up; + "Mod+Ctrl+I".action = move-workspace-down; + "Mod+Ctrl+O".action = move-workspace-up; + + # Mouse bindings + "Mod+WheelScrollDown" = { action = focus-workspace-down; cooldown-ms = 150; }; + "Mod+WheelScrollUp" = { action = focus-workspace-up; cooldown-ms = 150; }; + "Mod+Ctrl+WheelScrollDown" = { action = move-column-to-workspace-down; cooldown-ms = 150; }; + "Mod+Ctrl+WheelScrollUp" = { action = move-column-to-workspace-up; cooldown-ms = 150; }; + + "Mod+WheelScrollRight".action = focus-column-right; + "Mod+WheelScrollLeft".action = focus-column-left; + "Mod+Ctrl+WheelScrollRight".action = move-column-right; + "Mod+Ctrl+WheelScrollLeft".action = move-column-left; + + # You can refer to workspaces by index. However, keep in mind that + # niri is a dynamic workspace system, so these commands are kind of + # "best effort". Trying to refer to a workspace index bigger than + # the current workspace count will instead refer to the bottommost + # (empty) workspace. + # + # For example, with 2 workspaces + 1 empty, indices 3, 4, 5 and so on + # will all refer to the 3rd workspace. + "Mod+1".action = focus-workspace (workspaces."01".name); + "Mod+2".action = focus-workspace (workspaces."02".name); + "Mod+3".action = focus-workspace (workspaces."03".name); + "Mod+4".action = focus-workspace (workspaces."04".name); + "Mod+5".action = focus-workspace (workspaces."05".name); + "Mod+6".action = focus-workspace (workspaces."06".name); + "Mod+7".action = focus-workspace (workspaces."07".name); + "Mod+8".action = focus-workspace (workspaces."08".name); + "Mod+9".action = focus-workspace (workspaces."09".name); + "Mod+0".action = focus-workspace (workspaces."10".name); + "Mod+Ctrl+1".action = move-column-to-workspace (workspaces."01".name); + "Mod+Ctrl+2".action = move-column-to-workspace (workspaces."02".name); + "Mod+Ctrl+3".action = move-column-to-workspace (workspaces."03".name); + "Mod+Ctrl+4".action = move-column-to-workspace (workspaces."04".name); + "Mod+Ctrl+5".action = move-column-to-workspace (workspaces."05".name); + "Mod+Ctrl+6".action = move-column-to-workspace (workspaces."06".name); + "Mod+Ctrl+7".action = move-column-to-workspace (workspaces."07".name); + "Mod+Ctrl+8".action = move-column-to-workspace (workspaces."08".name); + "Mod+Ctrl+9".action = move-column-to-workspace (workspaces."09".name); + "Mod+Ctrl+0".action = move-column-to-workspace (workspaces."10".name); + + "Mod+asciicircum".action = focus-workspace (workspaces."99".name); + "Mod+Shift+asciicircum".action = move-column-to-workspace (workspaces."99".name); + + "Mod+Tab".action = focus-workspace-previous; + + "Mod+Comma".action = consume-or-expel-window-left; + "Mod+Period".action = consume-or-expel-window-right; + + "Mod+W".action = switch-preset-column-width; + "Mod+Shift+W".action = switch-preset-window-height; + "Mod+Ctrl+W".action = reset-window-height; + "Mod+F".action = maximize-column; + "Mod+Shift+F".action = fullscreen-window; + "Mod+E".action = center-column; + + "Mod+Minus".action = set-column-width "-10%"; + "Mod+At".action = set-column-width "+10%"; + "Mod+Shift+Minus".action = set-window-height "-10%"; + "Mod+Shift+At".action = set-window-height "+10%"; + + "Mod+V".action = switch-focus-between-floating-and-tiling; + "Mod+Shift+V".action = toggle-window-floating; + "Mod+Shift+Space".action = toggle-window-floating; # Sway compat + + "Print".action = screenshot; + "Ctrl+Print".action = screenshot-screen; + "Shift+Print".action = screenshot-window; + + "Mod+Shift+E".action = quit; + }; + }; + }; +} + diff --git a/home/modules/programs/my-waybar.nix b/home/modules/programs/my-waybar.nix index f9ffe30..0f9bcd7 100644 --- a/home/modules/programs/my-waybar.nix +++ b/home/modules/programs/my-waybar.nix @@ -45,11 +45,14 @@ in config.programs.waybar = let barWith = { showMedia ? true, showConnectivity ? true, extraSettings ? { }, ... }: lib.mkMerge ([{ + layer = "top"; position = "top"; modules-left = [ "sway/workspaces" "sway/mode" "sway/window" + "niri/workspaces" + "niri/window" ]; modules-center = [ ]; @@ -91,6 +94,19 @@ in "\\((\\d+)\\) Discord \\| (.*)" = "[🗨️] {$1} $2"; }; }; + "niri/window" = { + format = "{title}"; + "rewrite" = { + "(.*) — Mozilla Firefox" = "[🌎] $1"; + "(.*) - Mozilla Thunderbird" = "[📧] $1"; + "(.*) - Kakoune" = "[⌨️] $1"; + "(.*) - fish" = "[>_] $1"; + "(.*) - Discord" = "[🗨️] $1"; + # ArmCord thing + "• Discord \\| (.*)" = "[🗨️] $1"; + "\\((\\d+)\\) Discord \\| (.*)" = "[🗨️] {$1} $2"; + }; + }; "tray" = { icon-size = 21; spacing = 10; diff --git a/modules/common/linux/default.nix b/modules/common/linux/default.nix index 3b53a0d..0ccc742 100644 --- a/modules/common/linux/default.nix +++ b/modules/common/linux/default.nix @@ -45,12 +45,31 @@ let # services.gnome.evolution-data-server.plugins = with pkgs; [ evolution-ews ]; }; - wlr = { ... }: mkIf config.common.linux.enable { + wlr = { lib, config, ... }: mkIf config.common.linux.enable { # swaync disable notifications on screencast xdg.portal.wlr.settings.screencast = { exec_before = ''which swaync-client && swaync-client --inhibitor-add "xdg-desktop-portal-wlr" || true''; exec_after = ''which swaync-client && swaync-client --inhibitor-remove "xdg-desktop-portal-wlr" || true''; }; + + # Niri stuff + # https://github.com/sodiboo/niri-flake/blob/main/docs.md + programs.niri.enable = true; + programs.niri.package = pkgs.niri-stable; + systemd.user.services.niri = { + description = "A scrollable-tiling Wayland compositor"; + bindsTo = [ "graphical-session.target" ]; + before = [ "graphical-session.target" ]; + wants = [ "graphical-session-pre.target" ]; + after = [ "graphical-session-pre.target" ]; + + serviceConfig.Slice = "session.slice"; + serviceConfig.Type = "notify"; + serviceConfig.ExecStart = "${lib.getExe config.programs.niri.package} --session"; + path = mkForce [ ]; + }; + # Override gnome-keyring disabling + services.gnome.gnome-keyring.enable = lib.mkForce false; }; logitech = { pkgs, ... }: mkIf cfg.enable { @@ -343,6 +362,13 @@ in extraPortals = [ pkgs.kdePackages.xdg-desktop-portal-kde pkgs.xdg-desktop-portal-gtk ]; config.sway.default = [ "wlr" "kde" "kwallet" ]; + config.niri = { + default = [ "gnome" "gtk" ]; + "org.freedesktop.impl.portal.Access" = "gtk"; + "org.freedesktop.impl.portal.Notification" = "gtk"; + "org.freedesktop.impl.portal.Secret" = "kwallet"; + "org.freedesktop.impl.portal.FileChooser" = "kde"; + }; }; # D-Bus services.dbus.packages = with pkgs; [ gcr ]; From 6d42ec4acb93777ec792bba2a06c69b9bf4d254f Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Thu, 16 Jan 2025 06:08:54 +0100 Subject: [PATCH 17/24] Use mod+shift to move --- home/modules/programs/my-niri.nix | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/home/modules/programs/my-niri.nix b/home/modules/programs/my-niri.nix index d6311b2..260bffe 100644 --- a/home/modules/programs/my-niri.nix +++ b/home/modules/programs/my-niri.nix @@ -281,16 +281,16 @@ in "Mod+8".action = focus-workspace (workspaces."08".name); "Mod+9".action = focus-workspace (workspaces."09".name); "Mod+0".action = focus-workspace (workspaces."10".name); - "Mod+Ctrl+1".action = move-column-to-workspace (workspaces."01".name); - "Mod+Ctrl+2".action = move-column-to-workspace (workspaces."02".name); - "Mod+Ctrl+3".action = move-column-to-workspace (workspaces."03".name); - "Mod+Ctrl+4".action = move-column-to-workspace (workspaces."04".name); - "Mod+Ctrl+5".action = move-column-to-workspace (workspaces."05".name); - "Mod+Ctrl+6".action = move-column-to-workspace (workspaces."06".name); - "Mod+Ctrl+7".action = move-column-to-workspace (workspaces."07".name); - "Mod+Ctrl+8".action = move-column-to-workspace (workspaces."08".name); - "Mod+Ctrl+9".action = move-column-to-workspace (workspaces."09".name); - "Mod+Ctrl+0".action = move-column-to-workspace (workspaces."10".name); + "Mod+Shift+1".action = move-column-to-workspace (workspaces."01".name); + "Mod+Shift+2".action = move-column-to-workspace (workspaces."02".name); + "Mod+Shift+3".action = move-column-to-workspace (workspaces."03".name); + "Mod+Shift+4".action = move-column-to-workspace (workspaces."04".name); + "Mod+Shift+5".action = move-column-to-workspace (workspaces."05".name); + "Mod+Shift+6".action = move-column-to-workspace (workspaces."06".name); + "Mod+Shift+7".action = move-column-to-workspace (workspaces."07".name); + "Mod+Shift+8".action = move-column-to-workspace (workspaces."08".name); + "Mod+Shift+9".action = move-column-to-workspace (workspaces."09".name); + "Mod+Shift+0".action = move-column-to-workspace (workspaces."10".name); "Mod+asciicircum".action = focus-workspace (workspaces."99".name); "Mod+Shift+asciicircum".action = move-column-to-workspace (workspaces."99".name); From a376bc363e9022bb755bd328b6c8bf9ca5f8fa14 Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Thu, 16 Jan 2025 16:09:27 +0100 Subject: [PATCH 18/24] Update nixpkgs stable --- flake.lock | 22 +++------------------- 1 file changed, 3 insertions(+), 19 deletions(-) diff --git a/flake.lock b/flake.lock index 5f65832..0f1eb63 100644 --- a/flake.lock +++ b/flake.lock @@ -1092,11 +1092,11 @@ }, "nixpkgs_10": { "locked": { - "lastModified": 1734083684, - "narHash": "sha256-5fNndbndxSx5d+C/D0p/VF32xDiJCJzyOqorOYW4JEo=", + "lastModified": 1736916166, + "narHash": "sha256-puPDoVKxkuNmYIGMpMQiK8bEjaACcCksolsG36gdaNQ=", "owner": "nixos", "repo": "nixpkgs", - "rev": "314e12ba369ccdb9b352a4db26ff419f7c49fa84", + "rev": "e24b4c09e963677b1beea49d411cd315a024ad3a", "type": "github" }, "original": { @@ -1250,22 +1250,6 @@ "type": "github" } }, - "nixpkgs_9": { - "locked": { - "lastModified": 1723856861, - "narHash": "sha256-OTDg91+Zzs2SpU3csK4xVdSQFoG8cK1lNUwKmTqERyE=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "cd7b95ee3725af7113bacbce91dd6549cee58ca5", - "type": "github" - }, - "original": { - "owner": "NixOS", - "ref": "nixpkgs-unstable", - "repo": "nixpkgs", - "type": "github" - } - }, "nixpkgs_9": { "locked": { "lastModified": 1736549401, From 5125ebd2be941e8f0d6cc8793a38c0ce51c49e68 Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Thu, 16 Jan 2025 16:10:03 +0100 Subject: [PATCH 19/24] Add yoga internal monitor --- home/modules/monitors.nix | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/home/modules/monitors.nix b/home/modules/monitors.nix index 1b53096..f9180a5 100644 --- a/home/modules/monitors.nix +++ b/home/modules/monitors.nix @@ -8,6 +8,12 @@ let meta.mode = { width = 2256; height = 1504; refresh = 60.0; }; scale = 1.25; }; + "yoga" = { + name = "AU Optronics 0xD291 Unknown"; + meta.connection = "eDP-1"; + meta.mode = { width = 1920; height = 1080; refresh = 60.026; }; + scale = 1; + }; # External ## Work @ EPFL "work" = { From 0103e72ee663b1bf7a6fd9677cf4a612605e4c8e Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Thu, 16 Jan 2025 16:11:19 +0100 Subject: [PATCH 20/24] Move workspaces to a rebindable option --- home/modules/programs/my-niri.nix | 100 ++++++++++++++++++------------ 1 file changed, 60 insertions(+), 40 deletions(-) diff --git a/home/modules/programs/my-niri.nix b/home/modules/programs/my-niri.nix index 260bffe..a06df33 100644 --- a/home/modules/programs/my-niri.nix +++ b/home/modules/programs/my-niri.nix @@ -10,20 +10,6 @@ let wallpaper = config.linux.graphical.wallpaper; - workspaces = { - "01" = { name = "🌏 web"; }; - "02" = { name = "💬 chat"; }; - "03" = { name = "⚙️ code"; }; - "04" = { name = "🎶 music"; }; - "05" = { name = "🔧 extra"; }; - "06" = { name = "🧰 6"; }; - "07" = { name = "🔩 7"; }; - "08" = { name = "🛠️ 8"; }; - "09" = { name = "🔨 9"; }; - "10" = { name = "🎲 misc"; }; - "99" = { name = "📧 Email"; }; - }; - xwayland-display = ":12"; in @@ -44,9 +30,38 @@ in ++ (if wallpaper == "" then [ "" ] else [ "-i" "${wallpaper}" "-s" "fill" ]) ++ [ "-l" "-k" ]; }; + + workspaces = lib.mkOption { + type = lib.types.attrsOf + (lib.types.submodule { + options = { + name = lib.mkOption { type = lib.types.str; description = "workspace name"; }; + fixed = lib.mkOption { + type = lib.types.bool; + default = true; + description = "whether workspace always exists"; + }; + }; + }); + description = "A mapping of ordering to workspace names, for fixed workspaces"; + }; }; config = lib.mkIf cfg.enable { + programs.my-niri.workspaces = { + # Default workspaces, always there + "01" = { name = "🌏 web"; }; + "02" = { name = "💬 chat"; }; + "03" = { name = "⚙️ code"; }; + "04" = { name = "🎶 music"; }; + "05" = { name = "🔧 extra"; fixed = false; }; + "06" = { name = "🧰 6"; fixed = false; }; + "07" = { name = "🔩 7"; fixed = false; }; + "08" = { name = "🛠️ 8"; fixed = false; }; + "09" = { name = "🔨 9"; fixed = false; }; + "10" = { name = "🎲 misc"; fixed = false; }; + "99" = { name = "📧 Email"; fixed = false; }; + }; programs.niri.settings = { environment = { QT_QPA_PLATFORM = "wayland"; @@ -123,7 +138,12 @@ in prefer-no-csd = true; - inherit workspaces; + workspaces = + let + fixedWorkspaces = lib.filterAttrs (_: w: w.fixed) cfg.workspaces; + workspaceConfig = lib.mapAttrs (_: w: { inherit (w) name; }) fixedWorkspaces; + in + workspaceConfig; window-rules = [ # Rounded Corners @@ -133,7 +153,7 @@ in } # Workspace assignments { - open-on-workspace = workspaces."01".name; + open-on-workspace = cfg.workspaces."01".name; open-maximized = true; matches = [ { at-startup = true; app-id = "^firefox$"; } @@ -142,7 +162,7 @@ in ]; } { - open-on-workspace = workspaces."02".name; + open-on-workspace = cfg.workspaces."02".name; open-maximized = true; matches = [ { title = "^((d|D)iscord|((A|a)rm(c|C)ord))$"; } @@ -155,7 +175,7 @@ in ]; } { - open-on-workspace = workspaces."99".name; + open-on-workspace = cfg.workspaces."99".name; open-maximized = true; matches = [ { app-id = "thunderbird"; } @@ -271,29 +291,29 @@ in # # For example, with 2 workspaces + 1 empty, indices 3, 4, 5 and so on # will all refer to the 3rd workspace. - "Mod+1".action = focus-workspace (workspaces."01".name); - "Mod+2".action = focus-workspace (workspaces."02".name); - "Mod+3".action = focus-workspace (workspaces."03".name); - "Mod+4".action = focus-workspace (workspaces."04".name); - "Mod+5".action = focus-workspace (workspaces."05".name); - "Mod+6".action = focus-workspace (workspaces."06".name); - "Mod+7".action = focus-workspace (workspaces."07".name); - "Mod+8".action = focus-workspace (workspaces."08".name); - "Mod+9".action = focus-workspace (workspaces."09".name); - "Mod+0".action = focus-workspace (workspaces."10".name); - "Mod+Shift+1".action = move-column-to-workspace (workspaces."01".name); - "Mod+Shift+2".action = move-column-to-workspace (workspaces."02".name); - "Mod+Shift+3".action = move-column-to-workspace (workspaces."03".name); - "Mod+Shift+4".action = move-column-to-workspace (workspaces."04".name); - "Mod+Shift+5".action = move-column-to-workspace (workspaces."05".name); - "Mod+Shift+6".action = move-column-to-workspace (workspaces."06".name); - "Mod+Shift+7".action = move-column-to-workspace (workspaces."07".name); - "Mod+Shift+8".action = move-column-to-workspace (workspaces."08".name); - "Mod+Shift+9".action = move-column-to-workspace (workspaces."09".name); - "Mod+Shift+0".action = move-column-to-workspace (workspaces."10".name); + "Mod+1".action = focus-workspace (cfg.workspaces."01".name); + "Mod+2".action = focus-workspace (cfg.workspaces."02".name); + "Mod+3".action = focus-workspace (cfg.workspaces."03".name); + "Mod+4".action = focus-workspace (cfg.workspaces."04".name); + "Mod+5".action = focus-workspace (cfg.workspaces."05".name); + "Mod+6".action = focus-workspace (cfg.workspaces."06".name); + "Mod+7".action = focus-workspace (cfg.workspaces."07".name); + "Mod+8".action = focus-workspace (cfg.workspaces."08".name); + "Mod+9".action = focus-workspace (cfg.workspaces."09".name); + "Mod+0".action = focus-workspace (cfg.workspaces."10".name); + "Mod+Shift+1".action = move-column-to-workspace (cfg.workspaces."01".name); + "Mod+Shift+2".action = move-column-to-workspace (cfg.workspaces."02".name); + "Mod+Shift+3".action = move-column-to-workspace (cfg.workspaces."03".name); + "Mod+Shift+4".action = move-column-to-workspace (cfg.workspaces."04".name); + "Mod+Shift+5".action = move-column-to-workspace (cfg.workspaces."05".name); + "Mod+Shift+6".action = move-column-to-workspace (cfg.workspaces."06".name); + "Mod+Shift+7".action = move-column-to-workspace (cfg.workspaces."07".name); + "Mod+Shift+8".action = move-column-to-workspace (cfg.workspaces."08".name); + "Mod+Shift+9".action = move-column-to-workspace (cfg.workspaces."09".name); + "Mod+Shift+0".action = move-column-to-workspace (cfg.workspaces."10".name); - "Mod+asciicircum".action = focus-workspace (workspaces."99".name); - "Mod+Shift+asciicircum".action = move-column-to-workspace (workspaces."99".name); + "Mod+asciicircum".action = focus-workspace (cfg.workspaces."99".name); + "Mod+Shift+asciicircum".action = move-column-to-workspace (cfg.workspaces."99".name); "Mod+Tab".action = focus-workspace-previous; From c00150dd9594460f53cbd222e7f00e9c7b103ddf Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Thu, 16 Jan 2025 16:11:27 +0100 Subject: [PATCH 21/24] Add niri for yoga --- home/nki-x1c1.nix | 49 ++++++++++++++++++++++++++++++----------------- 1 file changed, 31 insertions(+), 18 deletions(-) diff --git a/home/nki-x1c1.nix b/home/nki-x1c1.nix index ce34779..e9ee09a 100644 --- a/home/nki-x1c1.nix +++ b/home/nki-x1c1.nix @@ -1,5 +1,20 @@ { pkgs, config, lib, ... }: +let + iio-sway = pkgs.stdenv.mkDerivation { + name = "iio-sway"; + version = "0.0.1"; + src = pkgs.fetchFromGitHub { + owner = "okeri"; + repo = "iio-sway"; + rev = "e07477d1b2478fede1446e97424a94c80767819d"; + hash = "sha256-JGacKajslCOvd/BFfFSf7s1/hgF6rJqJ6H6xNnsuMb4="; + }; + buildInputs = with pkgs; [ dbus ]; + nativeBuildInputs = with pkgs; [ meson ninja pkg-config ]; + meta.mainProgram = "iio-sway"; + }; +in { imports = [ # Common configuration @@ -49,25 +64,23 @@ startup = [ # rotation - ( - let - iio-sway = pkgs.stdenv.mkDerivation { - name = "iio-sway"; - version = "0.0.1"; - src = pkgs.fetchFromGitHub { - owner = "okeri"; - repo = "iio-sway"; - rev = "e07477d1b2478fede1446e97424a94c80767819d"; - hash = "sha256-JGacKajslCOvd/BFfFSf7s1/hgF6rJqJ6H6xNnsuMb4="; - }; - buildInputs = with pkgs; [ dbus ]; - nativeBuildInputs = with pkgs; [ meson ninja pkg-config ]; - }; - in - { command = "${iio-sway}/bin/iio-sway"; } - ) + { command = "${lib.getExe iio-sway}"; } ]; }; + programs.my-niri.enable = true; + programs.niri.settings = { + # input.keyboard.xkb.options = "ctrl:swapcaps"; + input.mouse = lib.mkForce { + # Make M575 fast for now + accel-profile = "adaptive"; + accel-speed = 0.4; + }; + input.touch.map-to-output = "eDP-1"; + switch-events = with config.lib.niri.actions; { + tablet-mode-on.action = spawn "systemctl" "--user" "kill" "--signal" "SIGUSR2" "wvkbd"; + tablet-mode-off.action = spawn "systemctl" "--user" "kill" "--signal" "SIGUSR1" "wvkbd"; + }; + }; ## Virtual keyboard systemd.user.services.wvkbd = { Unit = { @@ -99,7 +112,7 @@ settings = [ { profile.name = "undocked"; - profile.outputs = [{ criteria = "LVDS-1"; }]; + profile.outputs = [{ criteria = "eDP-1"; }]; } { profile.name = "work-both"; From 26df6113e76e9b3c8ac052b3a86f83a303f56128 Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Thu, 16 Jan 2025 18:10:23 +0100 Subject: [PATCH 22/24] Redesign targets for graphical --- home/modules/linux/graphical/default.nix | 30 ++++++++----- home/modules/linux/graphical/wayland.nix | 10 +++++ home/modules/programs/my-niri.nix | 54 ++++++++++++++++------- home/modules/programs/my-sway/default.nix | 4 ++ home/modules/programs/my-waybar.nix | 2 +- home/nki-framework.nix | 4 ++ home/nki-x1c1.nix | 2 + modules/common/linux/default.nix | 12 ----- 8 files changed, 78 insertions(+), 40 deletions(-) diff --git a/home/modules/linux/graphical/default.nix b/home/modules/linux/graphical/default.nix index 238f7fe..bf572d9 100644 --- a/home/modules/linux/graphical/default.nix +++ b/home/modules/linux/graphical/default.nix @@ -117,15 +117,6 @@ in ]; }; - # Yellow light! - services.wlsunset = { - enable = true; - - # Lausanne - latitude = "46.31"; - longitude = "6.38"; - }; - # Cursor home.pointerCursor = { package = pkgs.suwako-cursors; @@ -242,7 +233,6 @@ in qt.style.package = [ pkgs.kdePackages.breeze ]; qt.style.name = "Breeze"; - xdg.configFile = let f = pkg: { @@ -275,6 +265,26 @@ in # dconf.settings."desktop/ibus/general/hotkey" = { # triggers = hm.gvariant.mkArray hm.gvariant.type.string [ "z" ]; # }; + + # Some graphical targets + systemd.user.targets = { + # For system trays, usually after graphical-session and graphical-session-pre + tray = { + Unit.Description = lib.mkDefault "System tray"; + Unit.After = [ "graphical-session-pre.target" ]; + Unit.Before = [ "graphical-session.target" ]; + Unit.BindsTo = [ "graphical-session.target" ]; + Install.WantedBy = [ "graphical-session.target" ]; + }; + # XWayland target + xwayland = { + Unit.Description = "XWayland support"; + Unit.After = [ "graphical-session-pre.target" ]; + Unit.Before = [ "graphical-session.target" ]; + Unit.BindsTo = [ "graphical-session.target" ]; + Install.WantedBy = [ "graphical-session.target" ]; + }; + }; }; } diff --git a/home/modules/linux/graphical/wayland.nix b/home/modules/linux/graphical/wayland.nix index a0a0b27..6aa2b9f 100644 --- a/home/modules/linux/graphical/wayland.nix +++ b/home/modules/linux/graphical/wayland.nix @@ -100,6 +100,16 @@ with lib; ANKI_WAYLAND = "1"; }; + # Yellow light! + services.wlsunset = { + enable = true; + + # Lausanne + latitude = "46.31"; + longitude = "6.38"; + }; + + # Notification system # services.dunst = { # enable = true; diff --git a/home/modules/programs/my-niri.nix b/home/modules/programs/my-niri.nix index a06df33..c5dbc48 100644 --- a/home/modules/programs/my-niri.nix +++ b/home/modules/programs/my-niri.nix @@ -10,7 +10,7 @@ let wallpaper = config.linux.graphical.wallpaper; - xwayland-display = ":12"; + xwayland-display = ":0"; in { @@ -41,6 +41,11 @@ in default = true; description = "whether workspace always exists"; }; + monitor = lib.mkOption { + type = lib.types.nullOr lib.types.str; + default = null; + description = "Default monitor to spawn workspace in"; + }; }; }); description = "A mapping of ordering to workspace names, for fixed workspaces"; @@ -54,14 +59,33 @@ in "02" = { name = "💬 chat"; }; "03" = { name = "⚙️ code"; }; "04" = { name = "🎶 music"; }; - "05" = { name = "🔧 extra"; fixed = false; }; - "06" = { name = "🧰 6"; fixed = false; }; - "07" = { name = "🔩 7"; fixed = false; }; - "08" = { name = "🛠️ 8"; fixed = false; }; - "09" = { name = "🔨 9"; fixed = false; }; - "10" = { name = "🎲 misc"; fixed = false; }; - "99" = { name = "📧 Email"; fixed = false; }; + "05" = { name = "🔧 extra"; }; + "06" = { name = "🧰 6"; }; + "07" = { name = "🔩 7"; }; + "08" = { name = "🛠️ 8"; }; + "09" = { name = "🔨 9"; }; + "10" = { name = "🎲 misc"; }; + "99" = { name = "📧 Email"; }; }; + systemd.user.services.swaync.Install.WantedBy = [ "niri.service" ]; + systemd.user.services.swaync.Unit.After = [ "niri.service" ]; + systemd.user.targets.tray.Unit.After = [ "niri.service" ]; + systemd.user.targets.xwayland.Unit.After = [ "niri.service" ]; + + # xwayland-satellite + systemd.user.services.niri-xwayland-satellite = lib.mkIf cfg.enable { + Unit = { + Description = "XWayland Client for niri"; + PartOf = [ "xwayland.target" ]; + Before = [ "xwayland.target" "xdg-desktop-autostart.target" ]; + After = [ "niri.service" ]; + }; + Install.UpheldBy = [ "niri.service" ]; + Service.Slice = "session.slice"; + Service.Type = "notify"; + Service.ExecStart = "${lib.getExe pkgs.xwayland-satellite} ${xwayland-display}"; + }; + programs.niri.settings = { environment = { QT_QPA_PLATFORM = "wayland"; @@ -106,16 +130,8 @@ in spawn-at-startup = [ # Wallpaper { command = [ (lib.getExe pkgs.swaybg) "-i" "${wallpaper}" "-m" "fill" ]; } - # IME - { command = [ "fcitx5" ]; } - # XWayland - { command = [ (lib.getExe pkgs.xwayland-satellite) xwayland-display ]; } # Waybar - { command = [ "systemctl" "--user" "start" "swaync.service" ]; } { command = [ "systemctl" "--user" "start" "xdg-desktop-portal-gtk.service" "xdg-desktop-portal.service" ]; } - { command = [ "systemctl" "--user" "reset-failed" "waybar.service" "wlsunset.service" ]; } - # Startup - { command = [ (lib.getExe pkgs.dex) "-ae" "niri" ]; } ]; layout = { @@ -141,7 +157,11 @@ in workspaces = let fixedWorkspaces = lib.filterAttrs (_: w: w.fixed) cfg.workspaces; - workspaceConfig = lib.mapAttrs (_: w: { inherit (w) name; }) fixedWorkspaces; + workspaceConfig = lib.mapAttrs + (_: w: { inherit (w) name; } // (lib.optionalAttrs (w.monitor != null) { + open-on-output = w.monitor; + })) + fixedWorkspaces; in workspaceConfig; diff --git a/home/modules/programs/my-sway/default.nix b/home/modules/programs/my-sway/default.nix index 093f6e5..8117d87 100644 --- a/home/modules/programs/my-sway/default.nix +++ b/home/modules/programs/my-sway/default.nix @@ -91,6 +91,10 @@ in }; }; + config.systemd.user.targets.sway-session = mkIf cfg.enable { + Unit.Before = [ "tray.target" "xwayland.target" ]; + }; + # Enable waybar config.programs.my-waybar = mkIf cfg.enable { enable = true; diff --git a/home/modules/programs/my-waybar.nix b/home/modules/programs/my-waybar.nix index 0f9bcd7..84ec57a 100644 --- a/home/modules/programs/my-waybar.nix +++ b/home/modules/programs/my-waybar.nix @@ -256,7 +256,7 @@ in lib.mkIf cfg.enable { enable = true; systemd.enable = true; - systemd.target = "graphical-session.target"; + systemd.target = "tray.target"; settings = cfg.makeBars barWith; style = '' * { diff --git a/home/nki-framework.nix b/home/nki-framework.nix index 516c33f..3c995eb 100644 --- a/home/nki-framework.nix +++ b/home/nki-framework.nix @@ -46,6 +46,10 @@ tap = "enabled"; }; }; + programs.my-niri.enable = true; + programs.niri.settings = { + input.keyboard.xkb.options = "ctrl:swapcaps"; + }; programs.my-waybar.extraSettings = let change-mode = pkgs.writeScript "change-mode" '' diff --git a/home/nki-x1c1.nix b/home/nki-x1c1.nix index e9ee09a..0824a89 100644 --- a/home/nki-x1c1.nix +++ b/home/nki-x1c1.nix @@ -68,6 +68,8 @@ in ]; }; programs.my-niri.enable = true; + # Assign some of the workspaces to big screen + programs.my-niri.workspaces = lib.genAttrs [ "06" "07" "08" "09" "10" ] (_: { monitor = config.common.monitors.work.name; }); programs.niri.settings = { # input.keyboard.xkb.options = "ctrl:swapcaps"; input.mouse = lib.mkForce { diff --git a/modules/common/linux/default.nix b/modules/common/linux/default.nix index 0ccc742..36bef19 100644 --- a/modules/common/linux/default.nix +++ b/modules/common/linux/default.nix @@ -56,18 +56,6 @@ let # https://github.com/sodiboo/niri-flake/blob/main/docs.md programs.niri.enable = true; programs.niri.package = pkgs.niri-stable; - systemd.user.services.niri = { - description = "A scrollable-tiling Wayland compositor"; - bindsTo = [ "graphical-session.target" ]; - before = [ "graphical-session.target" ]; - wants = [ "graphical-session-pre.target" ]; - after = [ "graphical-session-pre.target" ]; - - serviceConfig.Slice = "session.slice"; - serviceConfig.Type = "notify"; - serviceConfig.ExecStart = "${lib.getExe config.programs.niri.package} --session"; - path = mkForce [ ]; - }; # Override gnome-keyring disabling services.gnome.gnome-keyring.enable = lib.mkForce false; }; From 379f9e602758496636e40cb3f325c46dcc2c3689 Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Fri, 17 Jan 2025 11:18:11 +0100 Subject: [PATCH 23/24] Make sway work on the same principles (no more waybar manual restarts ;D) --- home/modules/programs/my-niri.nix | 19 +++++++++++++++++++ home/modules/programs/my-sway/default.nix | 20 +++++++++++--------- home/modules/programs/my-waybar.nix | 5 ++++- 3 files changed, 34 insertions(+), 10 deletions(-) diff --git a/home/modules/programs/my-niri.nix b/home/modules/programs/my-niri.nix index c5dbc48..f08b43e 100644 --- a/home/modules/programs/my-niri.nix +++ b/home/modules/programs/my-niri.nix @@ -70,6 +70,8 @@ in systemd.user.services.swaync.Install.WantedBy = [ "niri.service" ]; systemd.user.services.swaync.Unit.After = [ "niri.service" ]; systemd.user.targets.tray.Unit.After = [ "niri.service" ]; + systemd.user.services.waybar.Unit.After = [ "niri.service" ]; + systemd.user.services.waybar.Install.WantedBy = [ "niri.service" ]; systemd.user.targets.xwayland.Unit.After = [ "niri.service" ]; # xwayland-satellite @@ -214,6 +216,23 @@ in ]; } + # xwaylandvideobridge + { + matches = [{ app-id = "^xwaylandvideobridge$"; }]; + open-floating = true; + focus-ring.enable = false; + opacity = 0.0; + default-floating-position = { + x = 0; + y = 0; + relative-to = "bottom-right"; + }; + min-width = 1; + max-width = 1; + min-height = 1; + max-height = 1; + } + # Kitty dimming { matches = [{ app-id = "kitty"; }]; diff --git a/home/modules/programs/my-sway/default.nix b/home/modules/programs/my-sway/default.nix index 8117d87..e073abf 100644 --- a/home/modules/programs/my-sway/default.nix +++ b/home/modules/programs/my-sway/default.nix @@ -92,7 +92,9 @@ in }; config.systemd.user.targets.sway-session = mkIf cfg.enable { - Unit.Before = [ "tray.target" "xwayland.target" ]; + Unit.Before = [ "tray.target" "xwayland.target" "xdg-desktop-portal.service" "xdg-desktop-autostart.target" ]; + Unit.Upholds = [ "waybar.service" ]; + Unit.Wants = [ "xdg-desktop-autostart.target" ]; }; # Enable waybar @@ -113,10 +115,10 @@ in ] ++ lib.optionals osConfig.services.desktopManager.plasma6.enable [ "XDG_MENU_PREFIX" ]; - systemd.extraCommands = options.wayland.windowManager.sway.systemd.extraCommands.default - ++ [ - "systemctl --user restart xdg-desktop-portal.service" - ]; + # systemd.extraCommands = options.wayland.windowManager.sway.systemd.extraCommands.default + # ++ [ + # "systemctl --user restart xdg-desktop-portal.service" + # ]; checkConfig = false; # Not working atm config = { @@ -145,10 +147,10 @@ in menu = "${pkgs.dmenu}/bin/dmenu_path | ${pkgs.bemenu}/bin/bemenu | ${pkgs.findutils}/bin/xargs swaymsg exec --"; # Startup startup = [ - # Dex for autostart - { command = "${pkgs.dex}/bin/dex -ae sway"; } - # Waybar - { command = "systemctl --user restart waybar"; always = true; } + # # Dex for autostart + # { command = "${pkgs.dex}/bin/dex -ae sway"; } + # # Waybar + # { command = "systemctl --user restart waybar"; always = true; } # IME { command = "fcitx5"; } ]; diff --git a/home/modules/programs/my-waybar.nix b/home/modules/programs/my-waybar.nix index 84ec57a..f8282f5 100644 --- a/home/modules/programs/my-waybar.nix +++ b/home/modules/programs/my-waybar.nix @@ -42,6 +42,9 @@ in default = ""; }; }; + config.systemd.user.services.waybar = lib.mkIf cfg.enable { + Unit.Before = [ "tray.target" ]; + }; config.programs.waybar = let barWith = { showMedia ? true, showConnectivity ? true, extraSettings ? { }, ... }: lib.mkMerge ([{ @@ -256,7 +259,7 @@ in lib.mkIf cfg.enable { enable = true; systemd.enable = true; - systemd.target = "tray.target"; + systemd.target = "sway-session.target"; settings = cfg.makeBars barWith; style = '' * { From b9163212a3450520cf45e86072f3e5bd34a01adf Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Fri, 17 Jan 2025 11:22:55 +0100 Subject: [PATCH 24/24] Add back rofi-rbw-script to niri --- home/modules/linux/graphical/wayland.nix | 1 + home/modules/programs/my-niri.nix | 1 + 2 files changed, 2 insertions(+) diff --git a/home/modules/linux/graphical/wayland.nix b/home/modules/linux/graphical/wayland.nix index 6aa2b9f..d44d534 100644 --- a/home/modules/linux/graphical/wayland.nix +++ b/home/modules/linux/graphical/wayland.nix @@ -66,6 +66,7 @@ let name = "rofi-rbw-script"; runtimeInputs = with pkgs; [ rofi wtype rofi-rbw ]; text = "rofi-rbw"; + meta.mainProgram = "rofi-rbw-script"; }; in with lib; diff --git a/home/modules/programs/my-niri.nix b/home/modules/programs/my-niri.nix index f08b43e..d62a175 100644 --- a/home/modules/programs/my-niri.nix +++ b/home/modules/programs/my-niri.nix @@ -258,6 +258,7 @@ in "Mod+Space".action = spawn (lib.getExe pkgs.rofi) "-show" "drun"; "Mod+R".action = sh app-menu; "Mod+Semicolon".action = spawn cfg.lock-command; + "Mod+Shift+P".action = spawn "rofi-rbw-script"; # Audio and Volume "XF86AudioPrev" = { action = spawn playerctl "previous"; allow-when-locked = true; };