Declaratively manage KDE Plasma (#4)

* init and keybinds

* add display and monitor config

* panel is now configured, need to do system tray

* setup system tray

* fix mice acceleration

* move .gtkrc-2.0 to workaround https://github.com/nix-community/plasma-manager/issues/472

* fix color schemes
This commit is contained in:
sadan4 2025-03-20 00:32:51 -04:00 committed by sadan
parent 729ebb9ad1
commit 33393a9986
No known key found for this signature in database
7 changed files with 296 additions and 0 deletions

View file

@ -0,0 +1,104 @@
{ screen }:
let
baseConfig = {
inherit screen;
floating = true;
height = 40;
# weird, see: https://github.com/nix-community/plasma-manager/issues/62#issuecomment-1986816749
hiding = "normalpanel";
lengthMode = "fit";
location = "top";
maxLength = null;
minLength = null;
offset = null;
opacity = "opaque";
};
in
builtins.map (section: baseConfig // section) [
{
alignment = "left";
widgets = [
{
kicker = {
icon = "nix-snowflake-white";
};
}
{
appMenu = {
};
}
];
}
{
alignment = "center";
widgets = [
{
iconTasks = {
# .desktop filenames
# 1. open app
# 2. drag app to desktop => copy here
# 3. open context menu => show target
# 4. copy filename
# 5. profit
launchers = builtins.map (filename: "applications:${filename}.desktop") [
"brave-browser"
"spotify"
"kitty"
"vesktop"
];
appearance = {
fill = false;
};
};
}
];
}
{
alignment = "right";
widgets = [
{
systemTray = {
icons = {
spacing = "small";
};
items = {
hidden = [
"flameshot"
# razer keybord lighting
"polychromatic-tray-applet"
"spotify-client"
# Electron apps all have the same id, see: https://github.com/electron/electron/issues/40936
# better to just filter them all out
"chrome_status_icon_1"
"org.kde.plasma.brightness"
# keyboard lang
"org.kde.plasma.keyboardlayout"
# caps lock, etc...
"org.kde.plasma.keyboardindicator"
# I would like for this to only show if sleep is being inhibited
# but it shows anytime the power profile is not the default
"org.kde.plasma.battery"
# I think this shows anytime you're saving clipboard history why???
"org.kde.plasma.clipboard"
# shows any time **any** media is playing or paused in the background
"org.kde.plasma.mediacontroller"
# always shown while notifications are enabled
"org.kde.plasma.notifications"
];
shown = [
"org.kde.plasma.volume"
"org.kde.plasma.networkmanagement"
];
};
};
}
{
digitalClock = {
time = {
format = "12h";
};
};
}
];
}
]

View file

@ -0,0 +1,99 @@
{ ... }:
let
makePanel = import ./_makePanel.nix;
in
{
programs = {
plasma = {
panels =
[ ] ++ (makePanel { screen = 0; }) ++ (makePanel { screen = 1; }) ++ (makePanel { screen = 2; });
configFile = {
"plasmashellrc" = {
# Monitor display numbers
# Seems to be the same order as screen priorities in settings > display & monitor > display configuration
# also seems to be the same as the ctrc value from the xrandr config
"ScreenConnectors" = {
"0" = "DisplayPort-1";
"1" = "HDMI-A-0";
"2" = "DisplayPort-0";
"3" = "DisplayPort-2";
};
};
};
};
autorandr = {
enable = true;
profiles = {
nix-desktop-evo4b5 = {
# nix-shell -p autorandr --run "autorandr --fingerprint"
fingerprint = {
DisplayPort-0 = "00ffffffffffff000472a501d207112001160104a52c197822ee91a3544c99260f5054bfee80714f81c08100a9c00101010101010101302a40c86084643018501300bbf91000001e000000fd00324c1e5010000a202020202020000000ff004c4e593038303033343232370a000000fc00416365722053323031484c0a2000f1";
DisplayPort-1 = "00ffffffffffff001e6d735b1ff1030003200104a5351e789fa435a5544f9e27125054a54b80317c4568457c617c8168818081bc953c023a801871382d40582c4500132a2100001e5a8780a070384d4030203a00132a2100001a000000fd003090aaaa24010a202020202020000000fc004c4720554c545241474541520a019f020318f1230907074b010203041112131f903f40830100008048801871382d40582c4500132a2100001e866f80a07038404030203500132a2100001efe5b80a07038354030203500132a21000018011d007251d01e206e285500132a2100001e000000ff003230334e545653374c3333350a0000000000000000000000000094";
DisplayPort-2 = "00ffffffffffff0006b3a12401010101341d010380351e78ea0ef5a555509e26105054bfef00714f818081409500a940b300d1cf0101023a801871382d40582c4500132b2100001e000000fd00284b1e5a19000a202020202020000000fc0056473234350a20202020202020000000ff004b434c4d51533038373739320a0103020327f14b900504030201111213141f230907078301000065030c001000681a00000101284be6023a801871382d40582c4500132b2100001e662156aa51001e30468f3300132b2100001e011d007251d01e206e285500132b2100001e8c0ad08a20e02d10103e9600132b2100001800000000000000000000000000000000b7";
HDMI-A-0 = "00ffffffffffff0010ac79a055324e302c1a010380342078eaee95a3544c99260f5054a1080081408180a940b300d1c0010101010101283c80a070b023403020360006442100001a000000ff003456333544364150304e32550a000000fc0044454c4c2055323431324d0a20000000fd00323d1e5311000a202020202020012e02031b61230907078301000067030c002000802d43908402e2000f8c0ad08a20e02d10103e9600a05a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000029";
};
# a lot of these values can be grabbed from `xrandr --query --verbose`
# or from `autorandr --save <config_name>` cd .config/autorandr/<config_name>/config
config = {
DisplayPort-1 = {
enable = true;
primary = true;
crtc = 0;
mode = "1920x1080";
position = "3520x1080";
rate = "143.98";
dpi = null;
filter = null;
gamma = "1.0:1.0:1.0";
rotate = null;
scale = null;
transform = null;
};
HDMI-A-0 = {
enable = true;
primary = false;
crtc = 3;
mode = "1920x1200";
position = "0x1080";
rate = "59.95";
dpi = null;
filter = null;
gamma = "1.0:1.0:1.0";
rotate = null;
scale = null;
transform = null;
};
DisplayPort-0 = {
enable = true;
primary = false;
crtc = 1;
mode = "1600x900";
position = "1920x1080";
rate = "60.00";
dpi = null;
filter = null;
gamma = "1.0:1.0:1.0";
rotate = null;
scale = null;
transform = null;
};
DisplayPort-2 = {
enable = true;
primary = false;
crtc = 2;
mode = "1920x1080";
position = "1719x0";
rate = "60.00";
dpi = null;
filter = null;
gamma = "1.0:1.0:1.0";
rotate = null;
scale = null;
transform = null;
};
};
};
};
};
};
}

View file

@ -1,4 +1,7 @@
{pkgs, ...}: {
imports = [
./plasma.nix
];
home = {
packages = with pkgs; [
kdePackages.filelight

View file

@ -0,0 +1,60 @@
{ inputs, config, ... }:
{
imports = [
inputs.plasma-manager.homeManagerModules.plasma-manager
# TODO: import dynamically based on hostname
./displays/nix-desktop-evo4b5.nix
];
# workaround https://github.com/nix-community/plasma-manager/issues/472
# This errors
# home.file.".gtkrc-2.0".force = true;
gtk.gtk2.configLocation = "${config.home.homeDirectory}/.config/.gtkrc-2.0";
programs = {
plasma = {
enable = true;
overrideConfig = true;
# input.mice is only on a per-mouse basis and doesnt have these settings
configFile = {
"kcminputrc" = {
Mouse = {
X11LibInputXAccelProfileFlat = true;
XLbInptAccelProfileFlat = true;
};
};
};
# Needed because our color scheme is overwritten
workspace = {
colorScheme = "TokyoNight";
# sleeping cat, installed from marketplace
# TODO: declaratively install things from the marketplace
splashScreen = {
theme = "a2n.kuro";
};
};
hotkeys = {
commands = {
"ocr" = {
name = "OCR";
key = "Meta+Shift+T";
command = "frog -e";
};
"flameshot" = {
name = "flameshot";
key = "Print";
command = "flameshot gui";
};
"rofi" = {
name = "rofi";
key = "Alt+P";
command = "rofi -show drun";
};
"kitty" = {
name = "kitty";
key = "Alt+Shift+Return";
command = "kitty";
};
};
};
};
};
}

View file

@ -37,6 +37,7 @@ in
};
};
home-manager = {
useUserPackages = true;
extraSpecialArgs = { inherit inputs stable unstable; };
users = {
"${NAME}" = import ./home.nix;

24
flake.lock generated
View file

@ -619,6 +619,29 @@
"type": "github"
}
},
"plasma-manager": {
"inputs": {
"home-manager": [
"home-manager-unstable"
],
"nixpkgs": [
"nixpkgs-unstable"
]
},
"locked": {
"lastModified": 1740569341,
"narHash": "sha256-WV8nY2IOfWdzBF5syVgCcgOchg/qQtpYh6LECYS9XkY=",
"owner": "nix-community",
"repo": "plasma-manager",
"rev": "5eeb0172fb74392053b66a8149e61b5e191b2845",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "plasma-manager",
"type": "github"
}
},
"root": {
"inputs": {
"ceserver": "ceserver",
@ -632,6 +655,7 @@
"nixos-wsl": "nixos-wsl",
"nixpkgs": "nixpkgs_4",
"nixpkgs-unstable": "nixpkgs-unstable",
"plasma-manager": "plasma-manager",
"scripts": "scripts",
"sops-nix": "sops-nix",
"spicetify-nix": "spicetify-nix",

View file

@ -25,6 +25,11 @@
url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgs-unstable";
};
plasma-manager = {
url = "github:nix-community/plasma-manager";
inputs.nixpkgs.follows = "nixpkgs-unstable";
inputs.home-manager.follows = "home-manager-unstable";
};
scripts = {
url = "github:sadan4/scripts";
};