nixfiles/home-manager/modules/ezpcusr.nix
2025-11-20 12:15:48 -07:00

413 lines
14 KiB
Nix

inputs: {
config,
lib,
pkgs,
...
}:
with lib; let
cfg = config.ezpcusr;
in {
imports = [
inputs.niri.homeModules.niri
inputs.noctalia.homeModules.default
];
options.ezpcusr = {
enable = mkEnableOption "Enable simple PC user config";
screenshotsPath = mkOption {
description = "Path to save screenshots in";
default = "$HOME/Media/Screenshots";
type = types.str;
};
screensaver = mkOption {
description = "ezpcusr screensaver";
default = {};
type = types.submodule {
options = {
lockTime = mkOption {
type = types.int;
default = 600;
description = "Time until your screen locks";
};
offTime = mkOption {
type = types.int;
default = 900;
description = "Time until your screen turns off";
};
};
};
};
bluetooth = mkOption {
type = types.bool;
default = false;
description = "If this PC has bluetooth support";
};
};
config = lib.mkIf cfg.enable {
services.hypridle = {
enable = lib.mkDefault true;
settings = {
general = {
lock_cmd = "noctalia-shell ipc call lockScreen lock";
before_sleep_cmd = "loginctl lock-session";
after_sleep_cmd = "hyperctl dispatch dpms on";
};
listener = [
{
timeout = cfg.screensaver.lockTime;
on-timeout = "loginctl lock-session";
}
{
timeout = cfg.screensaver.offTime;
on-timeout = "hyperctl dispatch dpms off";
}
];
};
};
services.wpaperd.enable = true;
# xdg.portal = {
# config.niri = {
# default = [ "gnome" "gtk" ];
# # "org.freedesktop.impl.portal.Access" = "gtk";
# # "org.freedesktop.impl.portal.Notification" = "gtk";
# # "org.freedesktop.impl.portal.Secret" = "gnome-keyring";
# # "org.freedesktop.impl.portal.FileChooser" = "gtk";
# };
# extraPortals = [ pkgs.xdg-desktop-portal-gtk ];
# };
programs.niri = {
enable = true;
package = pkgs.niri-unstable;
settings = {
window-rules = [
{draw-border-with-background = false;}
];
prefer-no-csd = true;
xwayland-satellite = {
enable = true;
path = lib.getExe pkgs.xwayland-satellite-unstable;
};
spawn-at-startup = [
{argv = ["noctalia-shell"];}
];
clipboard.disable-primary = true;
input = {
focus-follows-mouse.enable = true;
touchpad = {
click-method = "clickfinger";
natural-scroll = false;
};
};
binds =
{
"Mod+Return".action.spawn = "${config.programs.foot.package}/bin/foot";
"Mod+q".action = config.lib.niri.actions.close-window;
# "$mod, F, fullscreen, 0"
# "$mod SHIFT, F, fullscreen, 1"
# "$mod, Space, togglefloating"
# "$mod SHIFT, SPACE, exec, hyprctl switchxkblayout all next"
"Mod+d".action.spawn = ["noctalia-shell" "ipc" "call" "launcher" "toggle"];
"Print".action.spawn-sh = "grim - | satty -f -";
"Mod+c".action.spawn = ["noctalia-shell" "ipc" "call" "launcher" "clipboard"];
"Mod+Minus".action.spawn = ["noctalia-shell" "ipc" "call" "volume" "decrease"];
"Mod+Equal".action.spawn = ["noctalia-shell" "ipc" "call" "volume" "increase"];
"XF86AudioLowerVolume".action.spawn = ["noctalia-shell" "ipc" "call" "volume" "decrease"];
"XF86AudioRaiseVolume".action.spawn = ["noctalia-shell" "ipc" "call" "volume" "increase"];
"XF86AudioMute".action.spawn = ["noctalia-shell" "ipc" "call" "volume" "mute"];
"XF86AudioMicMute".action.spawn = ["noctalia-shell" "ipc" "call" "volume" "muteInput"];
"XF86MonBrightnessDown".action.spawn = ["noctalia-shell" "ipc" "call" "brightness" "decrease"];
"XF86MonBrightnessUp".action.spawn = ["noctalia-shell" "ipc" "call" "brightness" "increase"];
"Mod+Semicolon".action.spawn = ["noctalia-shell" "ipc" "call" "brightness" "decrease"];
"Mod+Apostrophe".action.spawn = ["noctalia-shell" "ipc" "call" "brightness" "increase"];
# Previous/next but change the shuffle/random state before action (and change back afterwards)
"Mod+Shift+Bracketright".action.spawn-sh = "${pkgs.playerctl}/bin/playerctl shuffle Toggle && ${pkgs.playerctl}/bin/playerctl next && ${pkgs.playerctl}/bin/playerctl shuffle Toggle";
"Mod+Shift+bracketleft".action.spawn-sh = "${pkgs.playerctl}/bin/playerctl shuffle Toggle && ${pkgs.playerctl}/bin/playerctl previous && ${pkgs.playerctl}/bin/playerctl shuffle Toggle";
"Shift+XF86AudioNext".action.spawn-sh = "${pkgs.playerctl}/bin/playerctl shuffle Toggle && ${pkgs.playerctl}/bin/playerctl next && ${pkgs.playerctl}/bin/playerctl shuffle Toggle";
"Shift+XF86AudioPrev".action.spawn-sh = "${pkgs.playerctl}/bin/playerctl shuffle Toggle && ${pkgs.playerctl}/bin/playerctl pref && ${pkgs.playerctl}/bin/playerctl shuffle Toggle";
# Previous/next
"Mod+Bracketright".action.spawn = ["noctalia-shell" "ipc" "call" "media" "next"];
"Mod+Bracketleft".action.spawn = ["noctalia-shell" "ipc" "call" "media" "previous"];
"XF86AudioNext".action.spawn = ["noctalia-shell" "ipc" "call" "media" "next"];
"XF86AudioPrev".action.spawn = ["noctalia-shell" "ipc" "call" "media" "previous"];
# Seek forward/back
"Mod+Control+bracketleft".action.spawn = ["noctalia-shell" "ipc" "call" "media" "seekRelative" "-5"];
"Mod+Control+bracketright".action.spawn = ["noctalia-shell" "ipc" "call" "media" "seekRelative" "5"];
"Control+XF86AudioPrev".action.spawn = ["noctalia-shell" "ipc" "call" "media" "seekRelative" "-5"];
"Control+XF86AudioNext".action.spawn = ["noctalia-shell" "ipc" "call" "media" "seekRelative" "5"];
# Toggle play/pause
"XF86AudioPlay".action.spawn = ["noctalia-shell" "ipc" "call" "media" "playPause"];
"XF86AudioPause".action.spawn = ["noctalia-shell" "ipc" "call" "media" "playPause"];
"Mod+Backslash".action.spawn = ["noctalia-shell" "ipc" "call" "media" "playPause"];
"Control+Alt+l".action.spawn = ["noctalia-shell" "ipc" "call" "lockScreen" "lock"];
"Mod+Shift+Slash".action = config.lib.niri.actions.show-hotkey-overlay;
"Mod+Left".action = config.lib.niri.actions.focus-column-left;
"Mod+Right".action = config.lib.niri.actions.focus-column-right;
# "Mod+Shift+Left".action = config.lib.niri.actions.move-column-left;
# "Mod+Shift+Right".action = config.lib.niri.actions.move-column-right;
"Mod+Shift+Left".action = config.lib.niri.actions.consume-or-expel-window-left;
"Mod+Shift+Right".action = config.lib.niri.actions.consume-or-expel-window-right;
"Mod+Down".action = config.lib.niri.actions.focus-window-or-workspace-down;
"Mod+Up".action = config.lib.niri.actions.focus-window-or-workspace-up;
"Mod+Shift+Down".action = config.lib.niri.actions.move-window-down-or-to-workspace-down;
"Mod+Shift+Up".action = config.lib.niri.actions.move-window-up-or-to-workspace-up;
# "Mod+Control+Left".action = config.lib.niri.actions.consume-or-expel-window-left;
# "Mod+Control+Right".action = config.lib.niri.actions.consume-or-expel-window-right;
"Mod+Space".action = config.lib.niri.actions.toggle-window-floating;
"Mod+F".action = config.lib.niri.actions.fullscreen-window;
"Mod+M".action = config.lib.niri.actions.maximize-column;
"Mod+O".action = config.lib.niri.actions.toggle-overview;
# "$mod, left, hy3:movefocus, l"
# "$mod, right, hy3:movefocus, r"
# "$mod, up, hy3:movefocus, u"
# "$mod, down, hy3:movefocus, d"
# "$mod, h, hy3:movefocus, l"
# "$mod, j, hy3:movefocus, d"
# "$mod, k, hy3:movefocus, u"
# "$mod, l, hy3:movefocus, r"
# "$mod SHIFT, left, hy3:movewindow, l"
# "$mod SHIFT, right, hy3:movewindow, r"
# "$mod SHIFT, up, hy3:movewindow, u"
# "$mod SHIFT, down, hy3:movewindow, d"
# "$mod SHIFT, h, hy3:movewindow, l"
# "$mod SHIFT, j, hy3:movewindow, d"
# "$mod SHIFT, k, hy3:movewindow, u"
# "$mod SHIFT, l, hy3:movewindow, r"
# "$mod CTRL, left, resizeactive, -80 0"
# "$mod CTRL, right, resizeactive, 80 0"
# "$mod CTRL, up, resizeactive, 0 -80"
# "$mod CTRL, down, resizeactive, 0 80"
# "$mod CTRL, h, resizeactive, -80 0"
# "$mod CTRL, j, resizeactive, 0 80"
# "$mod CTRL, k, resizeactive, 0 -80"
# "$mod CTRL, l, resizeactive, 80 0"
# "$mod, mouse_down, workspace, e-1"
# "$mod, mouse_up, workspace, e+1"
}
// (
# workspaces
# binds $mod + [shift +] {1..9} to [move to] workspace {1..9}
lib.listToAttrs (
builtins.concatLists (builtins.genList (
i: let
ws = i + 1;
in [
{
name = "Mod+${toString i}";
value = {action.focus-workspace = i;};
}
{
name = "Mod+Shift+${toString i}";
value = {action.move-window-to-workspace = i;};
}
# "$mod, code:1${toString i}, workspace, ${toString ws}"
# "$mod SHIFT, code:1${toString i}, movetoworkspace, ${toString ws}"
]
)
9)
)
);
};
};
programs.noctalia-shell = {
enable = true;
settings = {
appLauncher = {
terminalCommand = "${config.programs.foot.package}/bin/foot";
enableClipboardHistory = true;
};
general = {
compactLockScreen = true;
};
location = {
weatherEnabled = false;
use12hourFormat = true;
};
colorSchemes = {
generateTemplatesForPredefined = false;
};
ui = {
fontDefault = config.stylix.fonts.sansSerif.name;
fontFixed = config.stylix.fonts.monospace.name;
};
dock.enabled = false;
bar = {
floating = false;
backgroundOpacity = 0;
widgets = {
left = [
{
id = "Workspace";
}
{
id = "ActiveWindow";
width = 200;
}
];
center = [
{
id = "MediaMini";
maxWidth = 400;
scrollingMode = "always";
showVisualizer = true;
}
{
id = "Clock";
}
];
right = [
{
id = "Tray";
}
{
id = "NotificationHistory";
}
{
id = "Battery";
displayMode = "alwaysShow";
warningThreshold = 20;
}
{
id = "PowerProfile";
}
{
id = "Volume";
displayMode = "alwaysShow";
}
{
id = "WiFi";
}
{
id = "Bluetooth";
}
{
id = "ControlCenter";
}
];
};
};
};
colors = with config.lib.stylix.colors; {
mError = "#${base08}";
mOnError = "#${base00}";
mOnPrimary = "#${base00}";
mOnSecondary = "#${base00}";
mOnSurface = "#${base04}";
mOnSurfaceVariant = "#${base04}";
mOnTertiary = "#${base00}";
mOutline = "#${base02}";
mPrimary = "#${base0B}";
mSecondary = "#${base0A}";
mShadow = "#${base00}";
mSurface = "#${base00}";
mSurfaceVariant = "#${base01}";
mTertiary = "#${base0D}";
};
};
programs.librewolf.enable = true;
services.mpris-proxy.enable = lib.mkDefault true;
services.playerctld.enable = lib.mkDefault true;
programs.foot.enable = true;
xdg.enable = true;
xdg.userDirs.enable = true;
xdg.configFile."mimeapps.list".force = true;
xdg.mimeApps = let
applications = {
"inode/directory" = "pcmanfm-qt.desktop";
"text/html" = "librewolf.desktop";
"x-scheme-handler/http" = "librewolf.desktop";
"x-scheme-handler/https" = "librewolf.desktop";
"x-scheme-handler/about" = "librewolf.desktop";
"application/zip" = "ark.desktop";
"application/rar" = "ark.desktop";
"application/7z" = "ark.desktop";
"application/*tar" = "ark.desktop";
};
in {
enable = true;
associations.added = applications;
defaultApplications = applications;
};
programs.mpv.enable = lib.mkDefault true;
fonts.fontconfig.enable = lib.mkDefault true;
home.packages = with pkgs; [
nautilus # gnome portal file chooser
wl-clipboard
wtype
ydotool
keyutils
maim
slop
xorg.xhost
sway-contrib.grimshot
grim
inputs.noctalia.packages.${pkgs.system}.default
];
programs.satty = {
enable = true;
settings.general = {
fullscreen = true;
initial-tool = "crop";
early-exit = true;
copy-command = "wl-copy";
save-after-copy = true;
actions-on-enter = ["save-to-clipboard"];
actions-on-escape = ["exit"];
output-filename = "${config.home.homeDirectory}/Media/Screenshots/satty-%F_%T.png";
};
};
services.cliphist.enable = true;
};
}