From e4543eeb0ba5161d0fd4f37ed9523f6ea0335a52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kier=C3=A1n=20Meinhardt?= Date: Tue, 8 Jul 2025 20:56:40 +0200 Subject: [PATCH] sway --- configs/i3.nix | 13 ++++++ configs/keyboard.nix | 96 +++++++++++++++++++++++++++++++++---------- configs/packages.nix | 1 + configs/wallpaper.nix | 6 ++- 4 files changed, 93 insertions(+), 23 deletions(-) diff --git a/configs/i3.nix b/configs/i3.nix index 2f898f9..3c213f8 100644 --- a/configs/i3.nix +++ b/configs/i3.nix @@ -98,6 +98,8 @@ in { }; }; + security.pam.services.swaylock = {}; + services.xserver = { monitorSection = ''Option "DPMS" "false"''; serverFlagsSection = '' @@ -269,6 +271,8 @@ in { # XF86Launch1 (thinkvantage) }; in { + programs.swaylock.enable = true; + wayland.windowManager.sway = { enable = true; config = { @@ -279,6 +283,15 @@ in { xkb_layout = "de"; xkb_variant = "T3"; }; + "type:keyboard" = { + repeat_rate = "50"; + }; + "type:touchpad" = { + dwt = "enabled"; + dwtp = "enabled"; + tap = "enabled"; + tap_button_map = "lrm"; + }; }; terminal = (defaultApplications pkgs).terminal; up = "k"; diff --git a/configs/keyboard.nix b/configs/keyboard.nix index 05be284..ba8843a 100644 --- a/configs/keyboard.nix +++ b/configs/keyboard.nix @@ -2,27 +2,63 @@ pkgs, lib, ... -}: let +}: +let commaSep = builtins.concatStringsSep ","; - xkbOptions = ["compose:caps" "terminate:ctrl_alt_bksp" "grp:ctrls_toggle"]; + xkbOptions = [ + "compose:caps" + "terminate:ctrl_alt_bksp" + "grp:ctrls_toggle" + ]; languages = { - deutsch = { code = "de"; variant = "T3"; }; - greek = { code = "gr"; variant = "polytonic"; }; - russian = { code = "ru"; variant = "phonetic"; }; - arabic = { code = "ara"; variant = "buckwalter"; }; # ../lib/keyboards/arabic; + deutsch = { + code = "de"; + variant = "T3"; + }; + greek = { + code = "gr"; + variant = "polytonic"; + }; + russian = { + code = "ru"; + variant = "phonetic"; + }; + arabic = { + code = "ara"; + variant = "buckwalter"; + }; # ../lib/keyboards/arabic; coptic = ../lib/keyboards/coptic; avestan = ../lib/keyboards/avestan; gothic = ../lib/keyboards/gothic; - farsi = { code = "ir"; variant = "qwerty"; }; - syriac = { code = "sy"; variant = "syc_phonetic"; }; - sanskrit = { code = "in"; variant = "san-kagapa"; }; - gujarati = {code = "in"; variant = "guj-kagapa"; }; - urdu = {code = "in"; variant = "urd-phonetic"; }; - hebrew = {code = "il"; variant = "phonetic";}; + farsi = { + code = "ir"; + variant = "qwerty"; + }; + syriac = { + code = "sy"; + variant = "syc_phonetic"; + }; + sanskrit = { + code = "in"; + variant = "san-kagapa"; + }; + gujarati = { + code = "in"; + variant = "guj-kagapa"; + }; + urdu = { + code = "in"; + variant = "urd-phonetic"; + }; + hebrew = { + code = "il"; + variant = "phonetic"; + }; }; defaultLanguage = languages.deutsch; -in { +in +{ services.libinput.enable = true; # man 7 xkeyboard-config @@ -41,7 +77,8 @@ in { lib.mapAttrsToList (name: value: { name = "symbols/${name}"; path = value; - }) (lib.filterAttrs (_: value: !(value ? "code")) languages) ++ [ + }) (lib.filterAttrs (_: value: !(value ? "code")) languages) + ++ [ { name = "symbols/ir"; path = ../lib/keyboards/farsi; @@ -54,25 +91,40 @@ in { environment.etc."x11-locale".source = toString pkgs.xorg.libX11 + "share/X11/locale"; + home-manager.users.me = { + home.file = + lib.mapAttrs' (name: path: lib.nameValuePair ".xkb/symbols/${name}" { source = path; }) + (lib.filterAttrs (_: value: !(value ? "code")) languages) // { + ".xkb/symbols/ir".source = ../lib/keyboards/farsi; + }; + }; + console.keyMap = "de"; - environment.systemPackages = - lib.mapAttrsToList - (language: settings: + environment.systemPackages = lib.mapAttrsToList ( + language: settings: let code = if settings ? "code" then settings.code else language; variant = if settings ? "variant" then settings.variant else ""; in - pkgs.writers.writeDashBin "kb-${language}" '' - ${pkgs.xorg.setxkbmap}/bin/setxkbmap ${defaultLanguage.code},${code} ${defaultLanguage.variant},${variant} ${toString (map (option: "-option ${option}") xkbOptions)} - '') - languages; + pkgs.writers.writeDashBin "kb-${language}" '' + if [ -z $SWAYSOCK ]; then + ${pkgs.xorg.setxkbmap}/bin/setxkbmap ${defaultLanguage.code},${code} ${defaultLanguage.variant},${variant} ${ + toString (map (option: "-option ${option}") xkbOptions) + } + else + swaymsg -s $SWAYSOCK 'input * xkb_layout "${defaultLanguage.code},${code}"' + swaymsg -s $SWAYSOCK 'input * xkb_variant "${defaultLanguage.variant},${variant}"' + swaymsg -s $SWAYSOCK 'input * xkb_options "${lib.concatStringsSep "," xkbOptions}"' + fi + '' + ) languages; # improve held key rate services.xserver.displayManager.sessionCommands = "${pkgs.xorg.xset}/bin/xset r rate 300 50"; systemd.user.services.gxkb = { - wantedBy = ["graphical-session.target"]; + wantedBy = [ "graphical-session.target" ]; serviceConfig = { SyslogIdentifier = "gxkb"; ExecStart = "${pkgs.gxkb}/bin/gxkb"; diff --git a/configs/packages.nix b/configs/packages.nix index e57a7ea..4ecdf08 100644 --- a/configs/packages.nix +++ b/configs/packages.nix @@ -94,6 +94,7 @@ in { # HARDWARE TOOLS gnome-disk-utility arandr # xrandr for noobs + wdisplays libnotify # for notify-send xclip # clipboard CLI xdragon # drag and drop diff --git a/configs/wallpaper.nix b/configs/wallpaper.nix index 33a8ead..6420ec5 100644 --- a/configs/wallpaper.nix +++ b/configs/wallpaper.nix @@ -17,7 +17,11 @@ in { chmod o+rx ${stateDir} cd ${stateDir} (${pkgs.curl}/bin/curl -s -o wallpaper.tmp -z wallpaper.tmp ${lib.escapeShellArg url} && cp wallpaper.tmp wallpaper) || : - ${pkgs.feh}/bin/feh --no-fehbg --bg-scale wallpaper + if [ -z $SWAYSOCK ]; then + ${pkgs.feh}/bin/feh --no-fehbg --bg-scale wallpaper + else + ${pkgs.sway}/bin/swaymsg -s $SWAYSOCK 'output * bg ${stateDir}/wallpaper fill' + fi ''; startAt = "*:00,10,20,30,40,50"; serviceConfig = {