From 871acbd8e6735e76127c3584dac9f36e396be53f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Max=20K=C3=A4nner?= Date: Wed, 13 Mar 2024 21:51:32 +0100 Subject: [PATCH] 214 current 1970-01-01 01:00:00 24.05.20240303.b8697e5 6.6.19 * --- modules/home-manager/sway.nix | 111 +++++++++++++++++----------------- modules/nixos/sway.nix | 32 +--------- 2 files changed, 56 insertions(+), 87 deletions(-) diff --git a/modules/home-manager/sway.nix b/modules/home-manager/sway.nix index da81fa7..254ab7b 100644 --- a/modules/home-manager/sway.nix +++ b/modules/home-manager/sway.nix @@ -6,66 +6,65 @@ }: let schema = "org.gnome.desktop.a11y.applications"; key = "screen-keyboard-enabled"; - squeekboard_toggle = pkgs.writeTextFile { - name = "squeekboard_toggle"; - destination = "/bin/squeekboard_toggle"; - executable = true; - text = '' - #!${pkgs.bash}/bin/bash - if [ "$(gsettings get ${schema} ${key})" == "true" ]; then - gsettings set ${schema} ${key} false - else - gsettings set ${schema} ${key} true - fi - ''; - }; - squeekboard_format = pkgs.writeTextFile { - name = "squeekboard_format"; - destination = "/bin/squeekboard_format"; - executable = true; - text = '' - #!${pkgs.bash}/bin/bash - if [ "$(gsettings get ${schema} ${key})" == "true" ]; then - echo '{ "text": "󰌌", "tooltip": "enabled", "percentage": 100 }' - else - echo '{ "text": "󰌐", "tooltip": "disabled", "percentage": 0 }' - fi - ''; - }; - rotate_lisgd = pkgs.writeTextFile { - name = "rotate_lisgd"; - destination = "/bin/rotate_lisgd"; - executable = true; - text = '' - #!${pkgs.bash}/bin/bash - # PREV_ORIENTATION and ORIENTATION are given by rot8 + squeekboard_toggle = pkgs.writeShellScriptBin "squeekboard_toggle" '' + if [ "$(gsettings get ${schema} ${key})" == "true" ]; then + gsettings set ${schema} ${key} false + else + gsettings set ${schema} ${key} true + fi + ''; - LISGD_INPUT=/dev/input/by-path/platform-AMDI0010:02-event - # open nwggrid (Meta+D) by swiping up from the bottom edge - LISGD_ACTIONS=("1,DU,B,*,R,${pkgs.ydotool}/bin/ydotool key 125:1 32:1 32:0 125:0") - # close window (Meta+Shift+Q) by swiping down with 3 fingers - LISGD_ACTIONS+=("3,UD,*,L,R,${pkgs.ydotool}/bin/ydotool key 125:1 42:1 16:1 16:0 42:0 125:0") + squeekboard_format = pkgs.writeShellScriptBin "squeekboard_format" '' + if [ "$(gsettings get ${schema} ${key})" == "true" ]; then + echo '{ "text": "󰌌", "tooltip": "enabled", "percentage": 100 }' + else + echo '{ "text": "󰌐", "tooltip": "disabled", "percentage": 0 }' + fi + ''; - # move window left (Meta+Shift+H) by swiping left with 2 fingers - LISGD_ACTIONS+=("2,UD,*,*,R,${pkgs.ydotool}/bin/ydotool key 125:1 42:1 35:1 35:0 42:0 125:0") - # move window down (Meta+Shift+J) by swiping down with 2 fingers - LISGD_ACTIONS+=("2,UD,*,*,R,${pkgs.ydotool}/bin/ydotool key 125:1 42:1 36:1 36:0 42:0 125:0") - # move window up (Meta+Shift+K) by swiping up with 2 fingers - LISGD_ACTIONS+=("2,UD,*,*,R,${pkgs.ydotool}/bin/ydotool key 125:1 42:1 37:1 37:0 42:0 125:0") - # move window right (Meta+Shift+L) by swiping right with 2 fingers - LISGD_ACTIONS+=("2,UD,*,*,R,${pkgs.ydotool}/bin/ydotool key 125:1 42:1 38:1 38:0 42:0 125:0") + rotate_lisgd = pkgs.writeShellScriptBin "rotate_lisgd" '' + # PREV_ORIENTATION and ORIENTATION are given by rot8 - LISGD_ACTION_OPTIONS=() - for str in "''${LISGD_ACTIONS[@]}"; do - LISGD_ACTION_OPTIONS+=("-g" "$str") - done + LISGD_INPUT=/dev/input/by-path/platform-AMDI0010:02-event + # open nwggrid (Meta+D) by swiping up from the bottom edge + LISGD_ACTIONS=("1,DU,B,*,R,${pkgs.ydotool}/bin/ydotool key 125:1 32:1 32:0 125:0") + # close window (Meta+Shift+Q) by swiping down with 3 fingers + LISGD_ACTIONS+=("3,UD,*,L,R,${pkgs.ydotool}/bin/ydotool key 125:1 42:1 16:1 16:0 42:0 125:0") - ${pkgs.killall}/bin/killall lisgd + # move window left (Meta+Shift+H) by swiping left with 2 fingers + LISGD_ACTIONS+=("2,UD,*,*,R,${pkgs.ydotool}/bin/ydotool key 125:1 42:1 35:1 35:0 42:0 125:0") + # move window down (Meta+Shift+J) by swiping down with 2 fingers + LISGD_ACTIONS+=("2,UD,*,*,R,${pkgs.ydotool}/bin/ydotool key 125:1 42:1 36:1 36:0 42:0 125:0") + # move window up (Meta+Shift+K) by swiping up with 2 fingers + LISGD_ACTIONS+=("2,UD,*,*,R,${pkgs.ydotool}/bin/ydotool key 125:1 42:1 37:1 37:0 42:0 125:0") + # move window right (Meta+Shift+L) by swiping right with 2 fingers + LISGD_ACTIONS+=("2,UD,*,*,R,${pkgs.ydotool}/bin/ydotool key 125:1 42:1 38:1 38:0 42:0 125:0") - ${pkgs.lisgd}/bin/lisgd -v -d "$LISGD_INPUT" "''${LISGD_ACTION_OPTIONS[@]}" & - ''; - }; + LISGD_ACTION_OPTIONS=() + for str in "''${LISGD_ACTIONS[@]}"; do + LISGD_ACTION_OPTIONS+=("-g" "$str") + done + + ${pkgs.killall}/bin/killall lisgd + + ${pkgs.lisgd}/bin/lisgd -v -d "$LISGD_INPUT" "''${LISGD_ACTION_OPTIONS[@]}" & + ''; + + # bash script to let dbus know about impotant env variables and + # propagate them to relevent services run at the end of sway config + dbus-sway-environment = pkgs.writeShellScriptBin "dubs-sway-environment" '' + dbus-update-activation-environment --systemd WAYLAND_DISPLAY XDG_CURRENT_DESKTOP=sway + systemctl --user stop pipewire pipewire-media-session xdg-desktop-portal xdg-desktop-portal-wlr + systemctl --user start pipewire pipewire-media-session xdg-desktop-portal xdg-desktop-portal-wlr + ''; + + # currently, there is some friction between sway and gtk: + # https://github.com/swaywm/sway/wiki/GTK-3-settings-on-Wayland + configure-gtk = pkgs.writeShellScriptBin "configure-gtk" '' + gnome_schema=org.gnome.desktop.interface + gsettings set $gnome_schema gtk-theme 'Dracula' + ''; in { home.packages = with pkgs; [ waybar # status bar @@ -186,8 +185,8 @@ in { }; startup = [ - {command = "dbus-sway-environment";} - {command = "configure-gtk";} + {command = "${dbus-sway-environment}/bin/dbus-sway-environment";} + {command = "${configure-gtk}/bin/configure-gtk";} {command = "${pkgs.squeekboard}/bin/squeekboard";} {command = "${pkgs.rot8}/bin/rot8 -n 10 -h ${rotate_lisgd}/bin/rotate_lisgd";} {command = "${rotate_lisgd}/bin/rotate_lisgd";} diff --git a/modules/nixos/sway.nix b/modules/nixos/sway.nix index 6b59a49..1c7af82 100644 --- a/modules/nixos/sway.nix +++ b/modules/nixos/sway.nix @@ -3,39 +3,9 @@ pkgs, lib, ... -}: let - # bash script to let dbus know about impotant env variables and - # propagate them to relevent services run at the end of sway config - dbus-sway-environment = pkgs.writeTextFile { - name = "dubs-sway-environment"; - destination = "/bin/dbus-sway-environment"; - executable = true; - text = '' - dbus-update-activation-environment --systemd WAYLAND_DISPLAY XDG_CURRENT_DESKTOP=sway - systemctl --user stop pipewire pipewire-media-session xdg-desktop-portal xdg-desktop-portal-wlr - systemctl --user start pipewire pipewire-media-session xdg-desktop-portal xdg-desktop-portal-wlr - ''; - }; - - # currently, there is some friction between sway and gtk: - # https://github.com/swaywm/sway/wiki/GTK-3-settings-on-Wayland - configure-gtk = pkgs.writeTextFile { - name = "configure-gtk"; - destination = "/bin/configure-gtk"; - executable = true; - text = let - schema = pkgs.gsettings-desktop-schemas; - datadir = "${schema}/share/gsettings-schemas/${schema.name}"; - in '' - gnome_schema=org.gnome.desktop.interface - gsettings set $gnome_schema gtk-theme 'Dracula' - ''; - }; -in { +}: { environment.systemPackages = with pkgs; [ dbus # make dbus-update-activation-environment available in the path - dbus-sway-environment - configure-gtk wayland xdg-utils # for opening default programs when clicking links glib # gsettings