fixing up i3 and terminal inputs

This commit is contained in:
Noah Masur 2025-02-01 09:58:55 -05:00
parent f77f0c2fd6
commit ea3ab18cca
No known key found for this signature in database
4 changed files with 38 additions and 26 deletions

View File

@ -15,7 +15,7 @@ in
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
# Set the i3 terminal # Set the i3 terminal
xsession.windowManager.i3.config.terminal = lib.mkIf pkgs.stdenv.isLinux "kitty"; config.nmasur.presets.services.i3.terminal = pkgs.kitty;
# Set the Rofi terminal for running programs # Set the Rofi terminal for running programs
programs.rofi.terminal = lib.mkIf pkgs.stdenv.isLinux (lib.mkDefault "${pkgs.kitty}/bin/kitty"); programs.rofi.terminal = lib.mkIf pkgs.stdenv.isLinux (lib.mkDefault "${pkgs.kitty}/bin/kitty");

View File

@ -21,7 +21,7 @@ in
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
# Set the i3 terminal # Set the i3 terminal
xsession.windowManager.i3.config.terminal = lib.mkIf pkgs.stdenv.isLinux "wezterm"; config.nmasur.presets.services.i3.terminal = pkgs.wezterm;
# Display images in the terminal # Display images in the terminal
programs.fish.shellAliases = { programs.fish.shellAliases = {

View File

@ -13,6 +13,10 @@ in
options.nmasur.presets.services.i3 = { options.nmasur.presets.services.i3 = {
enable = lib.mkEnableOption "i3 window manager"; enable = lib.mkEnableOption "i3 window manager";
terminal = lib.mkOption {
type = lib.types.package;
description = "Terminal application to launch";
};
commands = { commands = {
launcher = lib.mkOption { launcher = lib.mkOption {
type = lib.types.nullOr lib.types.str; type = lib.types.nullOr lib.types.str;
@ -30,6 +34,9 @@ in
default = "${lib.getExe pkgs.betterlockscreen} --update ${config.wallpaper} --display 1 --span"; default = "${lib.getExe pkgs.betterlockscreen} --update ${config.wallpaper} --display 1 --span";
}; };
toggleBar = lib.mkOption { toggleBar = lib.mkOption {
type = lib.types.nullOr lib.types.str;
description = "Toggle menu bar panel";
default = null;
}; };
systemdSearch = lib.mkOption { systemdSearch = lib.mkOption {
type = lib.types.nullOr lib.types.str; type = lib.types.nullOr lib.types.str;
@ -82,6 +89,7 @@ in
ws10 = "10:X"; ws10 = "10:X";
in in
{ {
terminal = cfg.terminal.meta.mainProgram;
modifier = modifier; modifier = modifier;
assigns = { assigns = {
"${ws1}" = [ { class = "Firefox"; } ]; "${ws1}" = [ { class = "Firefox"; } ];
@ -169,33 +177,34 @@ in
"XF86AudioPrev" = "exec ${lib.getExe pkgs.playerctl} previous"; "XF86AudioPrev" = "exec ${lib.getExe pkgs.playerctl} previous";
# Launchers # Launchers
"${modifier}+Return" = "exec --no-startup-id ${ "${modifier}+Return" =
config.home-manager.users.${config.user}.programs.rofi.terminal "exec --no-startup-id ${lib.getExe cfg.terminal}; workspace ${ws2}; layout tabbed";
}; workspace ${ws2}; layout tabbed"; "${modifier}+space" =
"${modifier}+space" = "exec --no-startup-id ${cfg.commands.launcher}"; lib.mkIf cfg.commands.launcher != null "exec --no-startup-id ${cfg.commands.launcher}";
"${modifier}+Shift+s" = "exec --no-startup-id ${cfg.commands.systemdSearch}"; "${modifier}+Shift+s" =
"${modifier}+Shift+a" = "exec --no-startup-id ${cfg.commands.audioSwitch}"; lib.mkIf cfg.commands.systemdSearch != null "exec --no-startup-id ${cfg.commands.systemdSearch}";
"Mod1+Tab" = "exec --no-startup-id ${cfg.commands.altTab}"; "${modifier}+Shift+a" =
"${modifier}+Shift+period" = "exec --no-startup-id ${cfg.commands.power}"; lib.mkIf cfg.commands.audioSwitch != null "exec --no-startup-id ${cfg.commands.audioSwitch}";
"${modifier}+Shift+m" = "exec --no-startup-id ${cfg.commands.brightness}"; "Mod1+Tab" = lib.mkIf cfg.commands.altTab != null "exec --no-startup-id ${cfg.commands.altTab}";
"${modifier}+c" = "exec --no-startup-id ${cfg.commands.calculator}"; "${modifier}+Shift+period" =
lib.mkIf cfg.commands.power != null "exec --no-startup-id ${cfg.commands.power}";
"${modifier}+Shift+m" =
lib.mkIf cfg.commands.brightness != null "exec --no-startup-id ${cfg.commands.brightness}";
"${modifier}+c" =
lib.mkIf cfg.commands.calculator != null "exec --no-startup-id ${cfg.commands.calculator}";
"${modifier}+Shift+c" = "reload"; "${modifier}+Shift+c" = "reload";
"${modifier}+Shift+r" = "restart"; "${modifier}+Shift+r" = "restart";
"${modifier}+Shift+q" = "${modifier}+Shift+q" =
''exec "i3-nagbar -t warning -m 'You pressed the exit shortcut. Do you really want to exit i3? This will end your X session.' -B 'Yes, exit i3' 'i3-msg exit'"''; ''exec "i3-nagbar -t warning -m 'You pressed the exit shortcut. Do you really want to exit i3? This will end your X session.' -B 'Yes, exit i3' 'i3-msg exit'"'';
"${modifier}+Shift+x" = "exec ${cfg.commands.lockScreen}"; "${modifier}+Shift+x" = lib.mkIf cfg.commands.lockScreen != null "exec ${cfg.commands.lockScreen}";
"${modifier}+Mod1+h" = "${modifier}+Mod1+h" =
"exec --no-startup-id ${ "exec --no-startup-id ${lib.getExe cfg.terminal} -e sh -c '${pkgs.home-manager}/bin/home-manager switch --flake ${config.dotfilesPath}#${config.networking.hostName} || read'";
config.home-manager.users.${config.user}.programs.rofi.terminal
} -e sh -c '${pkgs.home-manager}/bin/home-manager switch --flake ${config.dotfilesPath}#${config.networking.hostName} || read'";
"${modifier}+Mod1+r" = "${modifier}+Mod1+r" =
"exec --no-startup-id ${ "exec --no-startup-id ${lib.getExe cfg.terminal} -e sh -c 'doas nixos-rebuild switch --flake ${config.dotfilesPath}#${config.networking.hostName} || read'";
config.home-manager.users.${config.user}.programs.rofi.terminal
} -e sh -c 'doas nixos-rebuild switch --flake ${config.dotfilesPath}#${config.networking.hostName} || read'";
# Window options # Window options
"${modifier}+q" = "kill"; "${modifier}+q" = "kill";
"${modifier}+b" = "exec ${config.toggleBarCommand}"; "${modifier}+b" = lib.mkIf cfg.commands.toggleBar "exec ${cfg.commands.toggleBar}";
"${modifier}+f" = "fullscreen toggle"; "${modifier}+f" = "fullscreen toggle";
"${modifier}+h" = "focus left"; "${modifier}+h" = "focus left";
"${modifier}+j" = "focus down"; "${modifier}+j" = "focus down";
@ -299,9 +308,10 @@ in
}; };
programs.fish.functions = { programs.fish.functions = {
update-lock-screen = lib.mkIf config.services.xserver.enable { update-lock-screen =
lib.mkIf cfg.commands.updateLockScreen != null {
description = "Update lockscreen with wallpaper"; description = "Update lockscreen with wallpaper";
body = lockUpdate; body = cfg.commands.updateLockScreen;
}; };
}; };
@ -310,10 +320,10 @@ in
let let
cacheDir = "${config.homePath}/.cache/betterlockscreen/current"; cacheDir = "${config.homePath}/.cache/betterlockscreen/current";
in in
lib.mkIf config.services.xserver.enable ( lib.mkIf cfg.commands.updateLockScreen != null (
config.lib.dag.entryAfter [ "writeBoundary" ] '' config.lib.dag.entryAfter [ "writeBoundary" ] ''
if [ ! -d ${cacheDir} ] || [ -z "$(ls ${cacheDir})" ]; then if [ ! -d ${cacheDir} ] || [ -z "$(ls ${cacheDir})" ]; then
$DRY_RUN_CMD ${lockUpdate} run ${cfg.commands.updateLockScreen}
fi fi
'' ''
); );

View File

@ -15,6 +15,8 @@ in
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
nmasur.presets.services.i3.commands.toggleBar = "polybar-msg cmd toggle";
services.polybar = { services.polybar = {
enable = true; enable = true;
package = pkgs.polybar.override { package = pkgs.polybar.override {