From a11957d85aee6b8820969e7a32d8b15f47f9540e Mon Sep 17 00:00:00 2001 From: Ingolf Wagner Date: Sat, 15 Jun 2024 20:10:06 +0200 Subject: [PATCH] restructure terminal stuff --- homes/common/terminal.nix | 3 + homes/palo/gui/alacritty.nix | 18 +++ homes/palo/gui/default.nix | 5 +- homes/palo/i3.nix | 274 +++++++++++++++-------------------- 4 files changed, 138 insertions(+), 162 deletions(-) create mode 100644 homes/palo/gui/alacritty.nix diff --git a/homes/common/terminal.nix b/homes/common/terminal.nix index 337b473..36a6c64 100644 --- a/homes/common/terminal.nix +++ b/homes/common/terminal.nix @@ -13,6 +13,9 @@ ''; }; + # to prevent strange errors + programs.kitty.enable = true; + programs.thefuck.enable = true; # a better cat diff --git a/homes/palo/gui/alacritty.nix b/homes/palo/gui/alacritty.nix new file mode 100644 index 0000000..d1d3846 --- /dev/null +++ b/homes/palo/gui/alacritty.nix @@ -0,0 +1,18 @@ +{ pkgs, lib, config, ... }: +with lib; +{ + + options.gui.alacritty.enable = mkOption { + type = lib.types.bool; + default = config.gui.enable; + }; + + config = lib.mkIf config.gui.alacritty.enable { + programs.alacritty = { + enable = true; + settings = { + font.size = mkForce 6.5; + }; + }; + }; +} diff --git a/homes/palo/gui/default.nix b/homes/palo/gui/default.nix index e2e7acc..ac7346e 100644 --- a/homes/palo/gui/default.nix +++ b/homes/palo/gui/default.nix @@ -1,3 +1,6 @@ { - imports = [ ./kitty.nix ]; + imports = [ + ./alacritty.nix + ./kitty.nix + ]; } diff --git a/homes/palo/i3.nix b/homes/palo/i3.nix index b3b536a..c479f21 100644 --- a/homes/palo/i3.nix +++ b/homes/palo/i3.nix @@ -1,8 +1,6 @@ { config, lib, pkgs, osConfig, ... }: let - cfg = config.xsession.windowManager.i3; - rofi = pkgs.rofi.override { plugins = [ pkgs.rofi-emoji pkgs.rofi-calc pkgs.xdotool ]; }; backgroundCommand = pkgs.writers.writeDash "background" '' @@ -26,8 +24,12 @@ let in { + options.gui.i3.enable = mkOption { + type = lib.types.bool; + default = config.gui.enable; + }; - config = lib.mkIf config.gui.enable { + config = lib.mkIf config.gui.i3.enable { home.packages = let @@ -42,8 +44,6 @@ in pkgs.xdotool # needed for rofi-emoji ]; - - programs.i3status-rust = { enable = true; bars = { @@ -118,12 +118,6 @@ in }; }; - programs.alacritty = { - enable = true; - settings = { - font.size = lib.mkForce 6.5; - }; - }; services.copyq = { enable = true; @@ -188,127 +182,131 @@ in ]; - keybindings = { - "Print" = "exec ${pkgs.flameshot}/bin/flameshot gui -c -p /share/"; - "${cfg.config.modifier}+Return" = "exec ${cfg.config.terminal}"; - "${cfg.config.modifier}+Shift+q" = "exit"; - "${cfg.config.modifier}+q" = "kill"; + keybindings = + let + cfg = config.xsession.windowManager.i3; + modifier = config.xsession.windowManager.i3.config.modifier; + in + { + "Print" = "exec ${pkgs.flameshot}/bin/flameshot gui -c -p /share/"; + "${modifier}+Return" = "exec ${cfg.config.terminal}"; + "${modifier}+Shift+q" = "exit"; + "${modifier}+q" = "kill"; - "${cfg.config.modifier}+Left" = "focus left"; - "${cfg.config.modifier}+Down" = "focus down"; - "${cfg.config.modifier}+Up" = "focus up"; - "${cfg.config.modifier}+Right" = "focus right"; - "${cfg.config.modifier}+j" = "focus next"; - "${cfg.config.modifier}+k" = "focus prev"; + "${modifier}+Left" = "focus left"; + "${modifier}+Down" = "focus down"; + "${modifier}+Up" = "focus up"; + "${modifier}+Right" = "focus right"; + "${modifier}+j" = "focus next"; + "${modifier}+k" = "focus prev"; - "${cfg.config.modifier}+Shift+Left" = "move left"; - "${cfg.config.modifier}+Shift+Down" = "move down"; - "${cfg.config.modifier}+Shift+Up" = "move up"; - "${cfg.config.modifier}+Shift+Right" = "move right"; + "${modifier}+Shift+Left" = "move left"; + "${modifier}+Shift+Down" = "move down"; + "${modifier}+Shift+Up" = "move up"; + "${modifier}+Shift+Right" = "move right"; - "${cfg.config.modifier}+h" = "split h"; - "${cfg.config.modifier}+v" = "split v"; - "${cfg.config.modifier}+f" = "fullscreen toggle"; + "${modifier}+h" = "split h"; + "${modifier}+v" = "split v"; + "${modifier}+f" = "fullscreen toggle"; - "${cfg.config.modifier}+s" = "layout stacking"; - "${cfg.config.modifier}+w" = "layout tabbed"; - "${cfg.config.modifier}+e" = "layout toggle split"; + "${modifier}+s" = "layout stacking"; + "${modifier}+w" = "layout tabbed"; + "${modifier}+e" = "layout toggle split"; - "${cfg.config.modifier}+t" = "floating toggle"; - #"${cfg.config.modifier}+space" = "focus mode_toggle"; + "${modifier}+t" = "floating toggle"; - "${cfg.config.modifier}+b" = "exec ${backgroundCommand}"; + "${modifier}+b" = "exec ${backgroundCommand}"; - "${cfg.config.modifier}+p" = "focus parent"; + "${modifier}+p" = "focus parent"; - "${cfg.config.modifier}+Shift+minus" = "move scratchpad"; - "${cfg.config.modifier}+minus" = "scratchpad show"; + "${modifier}+Shift+minus" = "move scratchpad"; + "${modifier}+minus" = "scratchpad show"; - "${cfg.config.modifier}+1" = "workspace 1"; - "${cfg.config.modifier}+2" = "workspace 2"; - "${cfg.config.modifier}+3" = "workspace 3"; - "${cfg.config.modifier}+4" = "workspace 4"; - "${cfg.config.modifier}+5" = "workspace 5"; - "${cfg.config.modifier}+6" = "workspace 6"; - "${cfg.config.modifier}+7" = "workspace 7"; - "${cfg.config.modifier}+8" = "workspace 8"; - "${cfg.config.modifier}+9" = "workspace 9"; - "${cfg.config.modifier}+0" = "workspace 10"; + "${modifier}+1" = "workspace 1"; + "${modifier}+2" = "workspace 2"; + "${modifier}+3" = "workspace 3"; + "${modifier}+4" = "workspace 4"; + "${modifier}+5" = "workspace 5"; + "${modifier}+6" = "workspace 6"; + "${modifier}+7" = "workspace 7"; + "${modifier}+8" = "workspace 8"; + "${modifier}+9" = "workspace 9"; + "${modifier}+0" = "workspace 10"; - "${cfg.config.modifier}+Shift+1" = "move container to workspace number 1"; - "${cfg.config.modifier}+Shift+2" = "move container to workspace number 2"; - "${cfg.config.modifier}+Shift+3" = "move container to workspace number 3"; - "${cfg.config.modifier}+Shift+4" = "move container to workspace number 4"; - "${cfg.config.modifier}+Shift+5" = "move container to workspace number 5"; - "${cfg.config.modifier}+Shift+6" = "move container to workspace number 6"; - "${cfg.config.modifier}+Shift+7" = "move container to workspace number 7"; - "${cfg.config.modifier}+Shift+8" = "move container to workspace number 8"; - "${cfg.config.modifier}+Shift+9" = "move container to workspace number 9"; - "${cfg.config.modifier}+Shift+0" = "move container to workspace number 10"; + "${modifier}+Shift+1" = "move container to workspace number 1"; + "${modifier}+Shift+2" = "move container to workspace number 2"; + "${modifier}+Shift+3" = "move container to workspace number 3"; + "${modifier}+Shift+4" = "move container to workspace number 4"; + "${modifier}+Shift+5" = "move container to workspace number 5"; + "${modifier}+Shift+6" = "move container to workspace number 6"; + "${modifier}+Shift+7" = "move container to workspace number 7"; + "${modifier}+Shift+8" = "move container to workspace number 8"; + "${modifier}+Shift+9" = "move container to workspace number 9"; + "${modifier}+Shift+0" = "move container to workspace number 10"; - "${cfg.config.modifier}+Escape" = "workspace back_and_forth"; + "${modifier}+Escape" = "workspace back_and_forth"; - # rename workspace - "${cfg.config.modifier}+n" = '' - exec i3-input -F 'rename workspace to "%s"' -P 'New name for this workspace: ' - ''; + # rename workspace + "${modifier}+n" = '' + exec i3-input -F 'rename workspace to "%s"' -P 'New name for this workspace: ' + ''; - # change to named workspace - "${cfg.config.modifier}+grave" = - let - script = pkgs.writers.writeBash "select-workspace" '' - set -e - set -o pipefail - ${pkgs.i3}/bin/i3-msg -t get_workspaces | \ - ${pkgs.jq}/bin/jq --raw-output '.[] | .name' | \ - ${rofi}/bin/rofi -dmenu -p 'Select Workspace ' | \ - while read line - do - ${pkgs.i3}/bin/i3-msg workspace "$line" - done - ''; - in - "exec ${script}"; + # change to named workspace + "${modifier}+grave" = + let + script = pkgs.writers.writeBash "select-workspace" '' + set -e + set -o pipefail + ${pkgs.i3}/bin/i3-msg -t get_workspaces | \ + ${pkgs.jq}/bin/jq --raw-output '.[] | .name' | \ + ${rofi}/bin/rofi -dmenu -p 'Select Workspace ' | \ + while read line + do + ${pkgs.i3}/bin/i3-msg workspace "$line" + done + ''; + in + "exec ${script}"; - "${cfg.config.modifier}+Shift+grave" = - let - script = pkgs.writers.writeBash "move-workspace" '' - set -e - set -o pipefail - ${pkgs.i3}/bin/i3-msg -t get_workspaces | \ - ${pkgs.jq}/bin/jq --raw-output '.[] | .name' | \ - ${rofi}/bin/rofi -dmenu -p 'Move to Workspace ' | \ - while read line - do - ${pkgs.i3}/bin/i3-msg move container to workspace "$line" - done - ''; - in - "exec ${script}"; + "${modifier}+Shift+grave" = + let + script = pkgs.writers.writeBash "move-workspace" '' + set -e + set -o pipefail + ${pkgs.i3}/bin/i3-msg -t get_workspaces | \ + ${pkgs.jq}/bin/jq --raw-output '.[] | .name' | \ + ${rofi}/bin/rofi -dmenu -p 'Move to Workspace ' | \ + while read line + do + ${pkgs.i3}/bin/i3-msg move container to workspace "$line" + done + ''; + in + "exec ${script}"; - "${cfg.config.modifier}+space" = "exec ${rofi}/bin/rofi -show drun -display-drun ''"; - "${cfg.config.modifier}+Shift+c" = "reload"; - "${cfg.config.modifier}+Shift+r" = "restart"; - "${cfg.config.modifier}+Shift+e" = "exec i3-nagbar -t warning -m 'Do you want to exit i3?' -b 'Yes' 'i3-msg exit'"; + "${modifier}+space" = "exec ${rofi}/bin/rofi -show drun -display-drun ''"; + "${modifier}+Shift+c" = "reload"; + "${modifier}+Shift+r" = "restart"; + "${modifier}+Shift+e" = "exec i3-nagbar -t warning -m 'Do you want to exit i3?' -b 'Yes' 'i3-msg exit'"; - "${cfg.config.modifier}+r" = "mode resize"; + "${modifier}+r" = "mode resize"; - # multiple monitors - # autorandr --save docked # to save setup - # autorandr --save undocked # to save setup - # autorandr --change # automatically detects the setup - "${cfg.config.modifier}+BackSpace" = - let - script = pkgs.writers.writeBash "autorandr" '' - ${pkgs.autorandr}/bin/autorandr --change - ${backgroundCommand} - ''; - in - "exec ${toString script}"; + # multiple monitors + # autorandr --save docked # to save setup + # autorandr --save undocked # to save setup + # autorandr --change # automatically detects the setup + "${modifier}+BackSpace" = + let + script = pkgs.writers.writeBash "autorandr" '' + ${pkgs.autorandr}/bin/autorandr --change + ${backgroundCommand} + ''; + in + "exec ${toString script}"; - # like vimperator - "${cfg.config.modifier}+a" = "exec ${pkgs.i3-easyfocus}/bin/i3-easyfocus"; - }; + # like vimperator + "${modifier}+a" = "exec ${pkgs.i3-easyfocus}/bin/i3-easyfocus"; + }; }; }; }; @@ -494,52 +492,6 @@ in }; }; - xdg.configFile."albert/albert.conf".text = '' - [General] - hotkey=Meta+Space - showTray=false - telemetry=false - terminal=urxvt -e - - [org.albert.extension.applications] - enabled=true - fuzzy=true - use_generic_name=true - use_keywords=true - - [org.albert.extension.calculator] - enabled=true - - [org.albert.extension.hashgenerator] - enabled=true - - [org.albert.frontend.widgetboxmodel] - alwaysOnTop=true - clearOnHide=false - displayIcons=true - displayScrollbar=false - displayShadow=false - hideOnClose=false - hideOnFocusLoss=true - itemCount=5 - showCentered=true - theme=SolarizedBrightViolet - ''; - - xdg.configFile."Code/User/settings.json".text = builtins.toJSON { - "keyboard.dispatch" = "keyCode"; - "explorer.confirmDragAndDrop" = false; - "editor.tabSize" = 2; - "window.zoomLevel" = -1; - "git.enableSmartCommit" = true; - "files.autoSave" = "onFocusChange"; - "terminal.integrated.setLocaleVariables" = true; - "terminal.external.linuxExec" = "xterm"; - "explorer.confirmDelete" = false; - "todo-tree.tags" = [ "todo" "TODO" "fixme" "FIXME" ]; - "workbench.colorTheme" = "Solarized Light"; - }; - - }; + }