From 555cedf9b65940526eb56d38b7ead423b2a5f76f Mon Sep 17 00:00:00 2001 From: Patrick Date: Wed, 13 Sep 2023 17:40:57 +0200 Subject: [PATCH] feat: switched back to X --- modules/graphical/xserver.nix | 21 + users/common/graphical/Xorg/autorandr.nix | 134 +++++++ users/common/graphical/Xorg/default.nix | 8 + users/common/graphical/Xorg/herbst-keys.nix | 92 +++++ users/common/graphical/Xorg/herbstluft.nix | 84 ++++ users/common/graphical/Xorg/polybar.nix | 368 ++++++++++++++++++ users/common/graphical/{ => Xorg}/rofi.nix | 3 +- users/common/graphical/Xorg/xinitrc | 24 ++ users/common/graphical/default.nix | 4 +- users/common/graphical/wayland/default.nix | 6 + .../common/graphical/{ => wayland}/fuzzel.nix | 0 .../{sway/default.nix => wayland/sway.nix} | 0 users/common/programs/bottles.nix | 12 + .../common/programs/nvim/lua/plugins/lsp.lua | 11 +- users/patrick/default.nix | 2 + users/patrick/impermanence.nix | 11 +- users/patrick/patrick.nix | 4 +- 17 files changed, 768 insertions(+), 16 deletions(-) create mode 100644 modules/graphical/xserver.nix create mode 100644 users/common/graphical/Xorg/autorandr.nix create mode 100644 users/common/graphical/Xorg/default.nix create mode 100644 users/common/graphical/Xorg/herbst-keys.nix create mode 100644 users/common/graphical/Xorg/herbstluft.nix create mode 100644 users/common/graphical/Xorg/polybar.nix rename users/common/graphical/{ => Xorg}/rofi.nix (74%) create mode 100644 users/common/graphical/Xorg/xinitrc create mode 100644 users/common/graphical/wayland/default.nix rename users/common/graphical/{ => wayland}/fuzzel.nix (100%) rename users/common/graphical/{sway/default.nix => wayland/sway.nix} (100%) create mode 100644 users/common/programs/bottles.nix diff --git a/modules/graphical/xserver.nix b/modules/graphical/xserver.nix new file mode 100644 index 0000000..ebea622 --- /dev/null +++ b/modules/graphical/xserver.nix @@ -0,0 +1,21 @@ +{ + # Configure keymap in X11 + services.xserver = { + enable = true; + displayManager.startx.enable = true; + autoRepeatDelay = 235; + autoRepeatInterval = 60; + videoDrivers = ["modesetting"]; + libinput = { + enable = true; + mouse.accelProfile = "flat"; + touchpad = { + accelProfile = "flat"; + accelSpeed = "0.5"; + naturalScrolling = true; + disableWhileTyping = true; + }; + }; + }; + services.autorandr.enable = true; +} diff --git a/users/common/graphical/Xorg/autorandr.nix b/users/common/graphical/Xorg/autorandr.nix new file mode 100644 index 0000000..bef51d8 --- /dev/null +++ b/users/common/graphical/Xorg/autorandr.nix @@ -0,0 +1,134 @@ +{ + config, + pkgs, + ... +}: { + programs.autorandr = let + dpi_hd = 96; + dpi_uhd = 216; + set_dpi = dpi: "echo 'Xft.dpi: ${toString dpi}' | ${pkgs.xorg.xrdb}/bin/xrdb -merge"; + eDP-1 = "00ffffffffffff0006afeb3000000000251b0104a5221378020925a5564f9b270c50540000000101010101010101010101010101010152d000a0f0703e803020350058c11000001852d000a0f07095843020350025a51000001800000000000000000000000000000000000000000002001430ff123caa8f0e29aa202020003e"; + # AStA config as function as we want to enable it for two different setups + asta_conf = { + DP-1-1, + DP-1-2, + }: { + fingerprint = { + inherit eDP-1 DP-1-1 DP-1-2; + }; + config = { + eDP-1 = { + enable = true; + primary = true; + mode = "3840x2160"; + position = "0x0"; + gamma = "1"; + }; + DP-1-1 = { + enable = true; + mode = "1920x1080"; + position = "3840x0"; + rate = "60"; + gamma = "1"; + }; + DP-1-2 = { + enable = true; + mode = "1920x1080"; + position = "5760x0"; + rate = "60"; + gamma = "1"; + }; + }; + hooks.postswitch = set_dpi dpi_hd; + }; + in { + enable = true; + + hooks.postswitch = { + "reload_wm" = "herbstclient reload"; + }; + + profiles.AStA_links = asta_conf { + # AStA linker arbeitsplatz linker Monitor + DP-1-1 = "00ffffffffffff000472ed0688687101111e010380351e782aa135a35b4fa327115054b30c00714f818081c081009500b300d1c001012a4480a070382740082098040f282100001a023a801871382d40582c45000f282100001e000000fd00304b1e5512000a202020202020000000fc00423234375920430a202020202001cf020327f14b9002030411121300001f01230907078301000065030c001000681a00000101304be6023a801871382d40582c45000f282100001e8c0ad08a20e02d10103e96000f2821000018011d007251d01e206e2855000f282100001e8c0ad090204031200c4055000f282100001800000000000000000000000000000000d0"; + # AStA linker arbeitsplatz rechter Monitor + DP-1-2 = "00ffffffffffff000472ed0682687101111e010380351e782aa135a35b4fa327115054b30c00714f818081c081009500b300d1c001012a4480a070382740082098040f282100001a023a801871382d40582c45000f282100001e000000fd00304b1e5512000a202020202020000000fc00423234375920430a202020202001d5020327f14b9002030411121300001f01230907078301000065030c001000681a00000101304be6023a801871382d40582c45000f282100001e8c0ad08a20e02d10103e96000f2821000018011d007251d01e206e2855000f282100001e8c0ad090204031200c4055000f282100001800000000000000000000000000000000d0"; + }; + profiles.AStA_rechts = asta_conf { + # AStA rechter arbeitsplatz linker Monitor + DP-1-1 = "00ffffffffffff000472ed068d687101111e010380351e782aa135a35b4fa327115054b30c00714f818081c081009500b300d1c001012a4480a070382740082098040f282100001a023a801871382d40582c45000f282100001e000000fd00304b1e5512000a202020202020000000fc00423234375920430a202020202001ca020327f14b9002030411121300001f01230907078301000065030c001000681a00000101304be6023a801871382d40582c45000f282100001e8c0ad08a20e02d10103e96000f2821000018011d007251d01e206e2855000f282100001e8c0ad090204031200c4055000f282100001800000000000000000000000000000000d0"; + # AStA rechter arbeitsplatz rechter Monitor + DP-1-2 = "00ffffffffffff000472ed0680687101111e010380351e782aa135a35b4fa327115054b30c00714f818081c081009500b300d1c001012a4480a070382740082098040f282100001a023a801871382d40582c45000f282100001e000000fd00304b1e5512000a202020202020000000fc00423234375920430a202020202001d7020327f14b9002030411121300001f01230907078301000065030c001000681a00000101304be6023a801871382d40582c45000f282100001e8c0ad08a20e02d10103e96000f2821000018011d007251d01e206e2855000f282100001e8c0ad090204031200c4055000f282100001800000000000000000000000000000000d0"; + }; + profiles = { + laptop = { + fingerprint = { + inherit eDP-1; + }; + config = { + eDP-1 = { + enable = true; + primary = true; + mode = "3840x2160"; + position = "0x0"; + gamma = "1"; + }; + }; + hooks.postswitch = set_dpi dpi_uhd; + }; + home_laptop = { + fingerprint = { + inherit eDP-1; + # Acer Predator Main Monitor + DP-1 = "00ffffffffffff00047290046bd08073261b0103803c227806ee91a3544c99260f505421080001010101010101010101010101010101565e00a0a0a029503020350056502100001a000000ff0023415350377974452f36413764000000fd001e9022de3b000a202020202020000000fc00584232373148550a202020202001750203204143030201230907018301000067030c001000007867d85dc40178c8005aa000a0a0a046503020350056502100001a6fc200a0a0a055503020350056502100001a6be600a0a0a0425030203a0056502100001e5a8700a0a0a03b503020350056502100001a1c2500a0a0a011503020350056502100001a00000000003c"; + }; + config = { + eDP-1 = { + enable = true; + primary = true; + mode = "3840x2160"; + position = "2560x0"; + gamma = "1"; + }; + DP-1 = { + enable = true; + mode = "2560x1440"; + position = "0x0"; + rate = "144"; + gamma = "1"; + }; + }; + hooks.postswitch = set_dpi dpi_hd; + }; + home_desktop = { + fingerprint = { + # Acer Predator Main Monitor + DP-4 = "00ffffffffffff00047290046bd08073261b0103803c227806ee91a3544c99260f505421080001010101010101010101010101010101565e00a0a0a029503020350056502100001a000000ff0023415350377974452f36413764000000fd001e9022de3b000a202020202020000000fc00584232373148550a202020202001750203204143030201230907018301000067030c001000007867d85dc40178c8005aa000a0a0a046503020350056502100001a6fc200a0a0a055503020350056502100001a6be600a0a0a0425030203a0056502100001e5a8700a0a0a03b503020350056502100001a1c2500a0a0a011503020350056502100001a00000000003c"; + DVI-D-0 = "00ffffffffffff004162850302ae60342e17010380301b78ca3935a25952a1270c5054bfef80714f8140818081c081009500b300d1c0023a801871382d40582c4500dd0c1100001e000000fd00384c1f5311000a202020202020000000fc00566973656f32323344580a2020000000ff004432524545303035383531300a00ed"; + HDMI-0 = "00ffffffffffff004c2d200d594d5a5a1c1a010380341d782a9315a655519c27115054bfef80714f81c0810081809500a9c0b3000101023a801871382d40582c450009252100001e000000fd00324b1e5111000a202020202020000000fc00533234463335300a2020202020000000ff0048345a483730383333310a202001ca020311b14690041f13120365030c001000011d00bc52d01e20b828554009252100001e8c0ad090204031200c4055000925210000188c0ad08a20e02d10103e9600092521000018000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000051"; + }; + config = { + DP-4 = { + enable = true; + primary = true; + mode = "2560x1440"; + position = "1920x720"; + gamma = "1"; + rate = "144"; + }; + DVI-D-0 = { + mode = "1920x1080"; + position = "0x0"; + rate = "60.00"; + }; + HDMI-0 = { + mode = "1920x1080"; + position = "0x1080"; + rate = "60.00"; + }; + }; + hooks.postswitch = set_dpi dpi_hd; + }; + }; + }; +} diff --git a/users/common/graphical/Xorg/default.nix b/users/common/graphical/Xorg/default.nix new file mode 100644 index 0000000..729c287 --- /dev/null +++ b/users/common/graphical/Xorg/default.nix @@ -0,0 +1,8 @@ +{ + imports = [ + ./herbstluft.nix + ./rofi.nix + ./polybar.nix + ./autorandr.nix + ]; +} diff --git a/users/common/graphical/Xorg/herbst-keys.nix b/users/common/graphical/Xorg/herbst-keys.nix new file mode 100644 index 0000000..0b014ed --- /dev/null +++ b/users/common/graphical/Xorg/herbst-keys.nix @@ -0,0 +1,92 @@ +MOD: TAGS: pkgs: +{ + # ${MOD} will be set to the main modifier key + + # General + "${MOD}-q" = " close"; + + # Moving + "${MOD}-Shift-Left" = " shift left"; + "${MOD}-Shift-Down" = " shift down"; + "${MOD}-Shift-Up" = " shift up"; + "${MOD}-Shift-Right" = " shift right"; + + "${MOD}-Shift-n" = " shift left"; + "${MOD}-Shift-r" = " shift down"; + "${MOD}-Shift-l" = " shift up"; + "${MOD}-Shift-s" = " shift right"; + + # Resizing + "${MOD}-Control-Left" = " resize left +$RESIZE_STEP"; + "${MOD}-Control-Down" = " resize down +$RESIZE_STEP"; + "${MOD}-Control-Up" = " resize up +$RESIZE_STEP"; + "${MOD}-Control-Right" = " resize right +$RESIZE_STEP"; + + "${MOD}-Control-n" = " resize left +$RESIZE_STEP"; + "${MOD}-Control-r" = " resize down +$RESIZE_STEP"; + "${MOD}-Control-l" = " resize up +$RESIZE_STEP"; + "${MOD}-Control-s" = " resize right +$RESIZE_STEP"; + + "${MOD}-Shift-Control-Left" = " resize right -$RESIZE_STEP"; + "${MOD}-Shift-Control-Down" = " resize up -$RESIZE_STEP"; + "${MOD}-Shift-Control-Up" = " resize down -$RESIZE_STEP"; + "${MOD}-Shift-Control-Right" = " resize left -$RESIZE_STEP"; + + "${MOD}-Shift-Control-s" = " resize right -$RESIZE_STEP"; + "${MOD}-Shift-Control-l" = " resize up -$RESIZE_STEP"; + "${MOD}-Shift-Control-r" = " resize down -$RESIZE_STEP"; + "${MOD}-Shift-Control-n" = " resize left -$RESIZE_STEP"; + + # Focusing + "${MOD}-Left" = " focus left"; + "${MOD}-Down" = " focus down"; + "${MOD}-Up" = " focus up"; + "${MOD}-Right" = " focus right"; + # Focusing + "${MOD}-n" = " focus left"; + "${MOD}-r" = " focus down"; + "${MOD}-l" = " focus up"; + "${MOD}-s" = " focus right"; + "Alt-Tab" = " cycle_all +1"; + "Alt-Shift-Tab" = " cycle_all -1"; + + "${MOD}-BackSpace" = " cycle_monitor"; + "${MOD}-c" = " cycle"; + "${MOD}-i" = " jumpto urgent"; + "${MOD}-Tab" = " cycle_all +1"; + "${MOD}-Shift-Tab" = " cycle_all -1"; + + # Tag cycle + "${MOD}-period" = " use_index +1 "; + "${MOD}-comma" = " use_index -1 "; + + # Splitting frames + "${MOD}-x" = " split bottom"; + "${MOD}-v" = " split right"; + "${MOD}-Control-space" = " split explode"; + + # Layouting + "${MOD}-Return" = " fullscreen toggle"; + "${MOD}-Shift-x" = " remove"; + "${MOD}-Shift-v" = " remove"; + "${MOD}-f" = " floating toggle"; + "${MOD}-p" = " pseudotile toggle"; + "${MOD}-space" = " cycle_layout +1"; + "${MOD}-Shift-space" = " cycle_layout -1"; + + "${MOD}-t " = "spawn kitty"; + "${MOD}-b " = "pawn ${pkgs.firefox}/bin/firefox"; + "${MOD}-m " = "spawn ${pkgs.thunderbird}/bin/thunderbird"; + "${MOD}-Shift-l " = "spawn systemctl suspend"; + "Menu" = "spawn rofi -show drun"; +} +// builtins.listToAttrs (map (x: { + name = "${MOD}-${x}"; + value = "use_index ${x}"; + }) + TAGS) +// builtins.listToAttrs (map (x: { + name = "${MOD}-Shift-${x}"; + value = "move_index ${x}"; + }) + TAGS) diff --git a/users/common/graphical/Xorg/herbstluft.nix b/users/common/graphical/Xorg/herbstluft.nix new file mode 100644 index 0000000..94d1bf6 --- /dev/null +++ b/users/common/graphical/Xorg/herbstluft.nix @@ -0,0 +1,84 @@ +{ + config, + pkgs, + lib, + ... +}: let + # set the modifier key to WIN + MOD = "Super"; + #set the default resize step for herbstluft + RESIZE_STEP = 0.05; + TAGS = map toString (lib.lists.range 1 9); +in { + home.file.".xinitrc".source = ./xinitrc; + xsession.windowManager.herbstluftwm = { + enable = true; + package = pkgs.herbstluftwm.overrideAttrs (finalAttrs: previousAttrs: { + doCheck = false; + }); + extraConfig = '' + herbstclient set auto_detect_monitors 1 + killall polybar + polybar & + + herbstclient attr theme.tiling.reset 1 + herbstclient attr theme.floating.reset 1 + herbstclient attr theme.active.color "#9fbc00" + herbstclient attr theme.normal.color "#454545" + herbstclient attr theme.urgent.color orange + herbstclient attr theme.inner_width 1 + herbstclient attr theme.inner_color black + herbstclient attr theme.border_width 3 + herbstclient attr theme.floating.border_width 4 + herbstclient attr theme.floating.outer_width 1 + herbstclient attr theme.floating.outer_color black + herbstclient attr theme.active.inner_color "#3E4A00" + herbstclient attr theme.active.outer_color "#3E4A00" + herbstclient attr theme.background_color "#141414" + ''; + + tags = TAGS; + + mousebinds = { + "${MOD}-Button1" = "move"; + "${MOD}-Button2" = "zoom"; + "${MOD}-Button3" = "resize"; + }; + + keybinds = import ./herbst-keys.nix MOD TAGS pkgs; + settings = { + "default_frame_layout" = 3; + + "frame_border_active_color" = "#222222"; + "frame_border_normal_color" = "#101010"; + "frame_bg_normal_color" = "#565656"; + "frame_bg_active_color" = "#345F0C"; + "frame_border_width" = 1; + "always_show_frame" = 1; + "frame_bg_transparent" = 1; + "frame_transparent_width" = 5; + "frame_gap" = 4; + + "window_gap" = 0; + "frame_padding" = 0; + "smart_window_surroundings" = 0; + "smart_frame_surroundings" = 1; + "mouse_recenter_gap" = 0; + + "tree_style" = "╾│ ├└╼─┐"; + }; + rules = [ + # Focus new clients by default + "focus=on" + + # Focus dialogs + "windowtype='_NET_WM_WINDOW_TYPE_DIALOG' focus=on" + + # Do not manage windows of type NOTIFICATION, DOCK, DESKTOP + "windowtype~'_NET_WM_WINDOW_TYPE_(NOTIFICATION|DOCK|DESKTOP)' manage=off" + + # Use pseudotiles for windows of type DIALOG, UTILITY, SPLASH + "windowtype~'_NET_WM_WINDOW_TYPE_(DIALOG|UTILITY|SPLASH)' pseudotile=on" + ]; + }; +} diff --git a/users/common/graphical/Xorg/polybar.nix b/users/common/graphical/Xorg/polybar.nix new file mode 100644 index 0000000..86f3a72 --- /dev/null +++ b/users/common/graphical/Xorg/polybar.nix @@ -0,0 +1,368 @@ +# Polybar config +# Polybar is kinda weird in two regards: +# 1. polybar allows a superkey and subkey to both have values eg: +# a = "lel" +# a.b = "lul" +# since nix does not allow this you have to hardcode the key with a '-' +# instead of using actual nix subkeys witt '.' eg: +# a = "lel" +# a-b = "lul" +# 2. polybar allows integer keys. In nix these have to be quoted +{ + lib, + pkgs, + nixosConfig, + ... +}: let + color = { + shade1 = "#311B92"; + shade2 = "#4527A0"; + shade3 = "#512DA8"; + shade4 = "#5E35B1"; + shade5 = "#673AB7"; + shade6 = "#7E57C2"; + shade7 = "#9575CD"; + shade8 = "#B39DDB"; + + bground = "#1D1F28"; + fground = "#f7f7f7"; + borderbg = "#f7f7f7"; + accent = "#5E35B1"; + modulefg = "#f7f7f7"; + modulefg-alt = "#f7f7f7"; + + trans = "#00000000"; + white = "#FFFFFF"; + black = "#000000"; + + # Material Colors + red = "#e53935"; + pink = "#d81b60"; + purple = "#8e24aa"; + deep-purple = "#5e35b1"; + indigo = "#3949ab"; + blue = "#1e88e5"; + light-blue = "#039be5"; + cyan = "#00acc1"; + teal = "#00897b"; + green = "#43a047"; + light-green = "#7cb342"; + lime = "#c0ca33"; + yellow = "#fdd835"; + amber = "#ffb300"; + orange = "#fb8c00"; + deep-orange = "#f4511e"; + brown = "#6d4c41"; + grey = "#757575"; + blue-gray = "#546e7a"; + }; + + fontsize = "9"; +in { + services.polybar = { + enable = true; + + package = pkgs.polybar.override { + pulseSupport = true; + alsaSupport = true; + iwSupport = true; + }; + + script = "polybar main @"; + settings = { + "bar/main" = + { + bottom = true; + offset.x = "0%"; + offset.y = "0%"; + + background = color.bground; + foreground = color.fground; + + font = { + "0" = "FiraCode Nerd Font Mono:style=Medium:size=${fontsize};2"; + "1" = ""; + "2" = "Iosevka Nerd Font:style=Medium:size=12;2"; + "3" = "Font Awesome 5 Pro:style=Solid:size=${fontsize}"; + "4" = "FontAwesome:style=Regular:size=${fontsize};2"; + "5" = "Font Awesome 5 Pro:style=Light:size=${fontsize}"; + }; + + modules = with lib; { + left = concatStringsSep " " ["left1" "title" "left2"]; + center = concatStringsSep " " ["workspaces"]; + right = concatStringsSep " " ["right5" "alsa" "right4" "battery" "right3" "network" "right2" "date" "right1" "keyboardswitcher"]; + }; + + tray = { + position = "right"; + background = color.shade1; + }; + + enable.ipc = true; + } + // { + desktopnix = { + monitor = "DP-4"; + # for HD Polybar + dpi = 96; + height = 22; + }; + patricknix = { + monitor = "DP-1"; + monitor-fallback = "eDP-1"; + # for UHD Polybar + dpi = 144; + height = 33; + }; + } + .${nixosConfig.node.name} + or {}; + + # Functional MODULES + + "module/title" = { + type = "internal/xwindow"; + + format = "