2024-03-06 23:02:59 +01:00
|
|
|
{
|
|
|
|
config,
|
|
|
|
pkgs,
|
|
|
|
lib,
|
|
|
|
...
|
2024-03-13 10:59:13 +01:00
|
|
|
}: let
|
2024-05-20 21:15:16 +02:00
|
|
|
cfg = config.myConfig.sway;
|
2024-05-18 15:03:55 +02:00
|
|
|
|
2024-03-13 21:51:32 +01:00
|
|
|
rotate_lisgd = pkgs.writeShellScriptBin "rotate_lisgd" ''
|
|
|
|
# PREV_ORIENTATION and ORIENTATION are given by rot8
|
|
|
|
|
2024-03-18 12:04:29 +01:00
|
|
|
LISGD_INPUT=/dev/input/event14
|
2024-03-18 11:09:11 +01:00
|
|
|
# open nwggrid by swiping up from the bottom edge
|
|
|
|
LISGD_ACTIONS=("1,DU,B,*,R,${pkgs.sway}/bin/swaymsg exec ${pkgs.nwg-launchers}/bin/nwggrid -client")
|
|
|
|
# close window by swiping down with 3 fingers
|
|
|
|
LISGD_ACTIONS+=("3,UD,*,L,R,${pkgs.sway}/bin/swaymsg kill")
|
2024-03-13 21:51:32 +01:00
|
|
|
|
2024-03-18 11:09:11 +01:00
|
|
|
# move window left by swiping left with 2 fingers
|
|
|
|
LISGD_ACTIONS+=("2,UD,*,*,R,${pkgs.sway}/bin/swaymsg move left")
|
|
|
|
# move window down by swiping down with 2 fingers
|
|
|
|
LISGD_ACTIONS+=("2,UD,*,*,R,${pkgs.sway}/bin/swaymsg move down")
|
|
|
|
# move window up by swiping up with 2 fingers
|
|
|
|
LISGD_ACTIONS+=("2,UD,*,*,R,${pkgs.sway}/bin/swaymsg move up")
|
|
|
|
# move window right by swiping right with 2 fingers
|
|
|
|
LISGD_ACTIONS+=("2,UD,*,*,R,${pkgs.sway}/bin/swaymsg move right")
|
2024-03-13 21:51:32 +01:00
|
|
|
|
|
|
|
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
|
2024-03-13 22:18:07 +01:00
|
|
|
dbus-sway-environment = pkgs.writeShellScriptBin "dbus-sway-environment" ''
|
2024-03-13 21:51:32 +01:00
|
|
|
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
|
|
|
|
'';
|
2024-03-13 10:59:13 +01:00
|
|
|
in {
|
2024-05-18 16:24:54 +02:00
|
|
|
imports = [./kanshi.nix ./waybar.nix ./theme.nix ./mako.nix];
|
2024-05-18 14:33:22 +02:00
|
|
|
|
2024-05-20 21:15:16 +02:00
|
|
|
options.myConfig.sway = {
|
|
|
|
enable = lib.mkEnableOption "sway, a lightweight window manager";
|
|
|
|
laptop = lib.mkEnableOption "laptop config";
|
2024-05-18 15:03:55 +02:00
|
|
|
};
|
2024-03-06 23:02:59 +01:00
|
|
|
|
2024-05-18 15:03:55 +02:00
|
|
|
config = lib.mkIf cfg.enable {
|
2024-05-20 21:15:16 +02:00
|
|
|
myConfig.sway = {
|
|
|
|
kanshi.enable = lib.mkDefault true;
|
|
|
|
waybar.enable = lib.mkDefault true;
|
|
|
|
theming.enable = lib.mkDefault true;
|
|
|
|
mako.enable = lib.mkDefault true;
|
|
|
|
waybar.battery = lib.mkIf cfg.laptop (lib.mkDefault true);
|
|
|
|
waybar.backlight = lib.mkIf cfg.laptop (lib.mkDefault true);
|
|
|
|
waybar.squeekboard = lib.mkIf cfg.laptop (lib.mkDefault true);
|
2024-05-21 13:32:45 +02:00
|
|
|
kanshi.laptop = lib.mkIf cfg.laptop (lib.mkDefault true);
|
2024-05-20 21:15:16 +02:00
|
|
|
};
|
2024-05-18 15:03:55 +02:00
|
|
|
|
|
|
|
home.packages = with pkgs; [
|
|
|
|
swaylock # screen locking
|
|
|
|
swayidle # automatic screen locking after system idle time
|
|
|
|
foot # terminal
|
|
|
|
keepassxc # used for secrets instead of gnome-keyring
|
|
|
|
];
|
|
|
|
|
|
|
|
wayland.windowManager.sway = {
|
2024-03-06 23:02:59 +01:00
|
|
|
enable = true;
|
2024-05-18 15:03:55 +02:00
|
|
|
systemd = {
|
|
|
|
enable = true;
|
|
|
|
xdgAutostart = false;
|
2024-03-10 10:15:35 +01:00
|
|
|
};
|
2024-03-10 10:55:16 +01:00
|
|
|
|
2024-05-18 15:03:55 +02:00
|
|
|
wrapperFeatures = {
|
|
|
|
gtk = true;
|
2024-03-06 23:02:59 +01:00
|
|
|
};
|
2024-03-10 10:55:16 +01:00
|
|
|
|
2024-05-18 15:03:55 +02:00
|
|
|
config = {
|
|
|
|
output = let
|
|
|
|
bgdir = ../../../assets;
|
|
|
|
bg1080 = bgdir + "/bg1080.png";
|
|
|
|
bg1080vert = bgdir + "/bg1080vert.png";
|
|
|
|
bg4k = bgdir + "/bg4k.png";
|
2024-05-18 16:24:54 +02:00
|
|
|
in
|
|
|
|
lib.mkIf cfg.laptop {
|
|
|
|
eDP-1 = {
|
|
|
|
bg = "'${bg1080}' fit";
|
|
|
|
};
|
|
|
|
HDMI-A-1 = {
|
|
|
|
bg = "'${bg4k}' fit";
|
|
|
|
};
|
|
|
|
DP-3 = {
|
|
|
|
bg = "'${bg1080}' fit";
|
|
|
|
};
|
|
|
|
DP-4 = {
|
|
|
|
bg = "'${bg1080}' fit";
|
|
|
|
};
|
|
|
|
DP-5 = {
|
|
|
|
bg = "'${bg1080vert}' fit";
|
|
|
|
};
|
|
|
|
DP-6 = {
|
|
|
|
bg = "'${bg1080}' fit";
|
|
|
|
};
|
|
|
|
DP-7 = {
|
|
|
|
bg = "'${bg1080vert}' fit";
|
|
|
|
};
|
2024-05-18 15:03:55 +02:00
|
|
|
};
|
2024-03-10 10:55:16 +01:00
|
|
|
|
2024-05-18 15:03:55 +02:00
|
|
|
input = {
|
|
|
|
"*" = {
|
|
|
|
xkb_layout = "de";
|
|
|
|
xkb_options = "caps:ctrl_modifier";
|
|
|
|
xkb_numlock = "enable";
|
|
|
|
};
|
2024-05-18 16:24:54 +02:00
|
|
|
"type:touchpad" = lib.mkIf cfg.laptop {
|
2024-05-18 15:03:55 +02:00
|
|
|
tap = "enable";
|
|
|
|
natural_scroll = "enable";
|
|
|
|
};
|
|
|
|
# map laptop touchscreen to laptop display
|
2024-05-18 16:24:54 +02:00
|
|
|
"1267:11676:ELAN2513:00_04F3:2D9C" = lib.mkIf cfg.laptop {
|
2024-05-18 15:03:55 +02:00
|
|
|
map_to_output = "'AU Optronics 0x4B2D Unknown'";
|
|
|
|
};
|
|
|
|
# map laptop stylus to laptop display
|
2024-05-18 16:24:54 +02:00
|
|
|
"1267:11676:ELAN2513:00_04F3:2D9C_Stylus" = lib.mkIf cfg.laptop {
|
2024-05-18 15:03:55 +02:00
|
|
|
map_to_output = "'AU Optronics 0x4B2D Unknown'";
|
|
|
|
};
|
2024-03-06 23:02:59 +01:00
|
|
|
};
|
2024-03-10 10:55:16 +01:00
|
|
|
|
2024-05-18 15:03:55 +02:00
|
|
|
modifier = "Mod4";
|
|
|
|
keybindings = let
|
|
|
|
modifier = config.wayland.windowManager.sway.config.modifier;
|
|
|
|
in
|
|
|
|
lib.mkOptionDefault {
|
|
|
|
# special workspaces
|
|
|
|
"${modifier}+1" = "workspace main";
|
|
|
|
"${modifier}+2" = "workspace term";
|
|
|
|
"${modifier}+3" = "workspace msg";
|
|
|
|
"${modifier}+4" = "workspace music";
|
|
|
|
"${modifier}+Shift+1" = "move container to workspace main";
|
|
|
|
"${modifier}+Shift+2" = "move container to workspace term";
|
|
|
|
"${modifier}+Shift+3" = "move container to workspace msg";
|
|
|
|
"${modifier}+Shift+4" = "move container to workspace music";
|
|
|
|
|
|
|
|
# screen capture
|
|
|
|
"${modifier}+Print" = ''exec ${pkgs.grim}/bin/grim -g "$(${pkgs.slurp}/bin/slurp)" - | ${pkgs.wl-clipboard}/bin/wl-copy'';
|
|
|
|
"${modifier}+Shift+Print" = ''exec ${pkgs.wf-recorder}/bin/wf-recorder -g "$(${pkgs.slurp}/bin/slurp)" -f "$HOME/Videos/screencapture_$(${pkgs.coreutils}/bin/date +%F-%T).mp4"'';
|
|
|
|
|
|
|
|
# brightness
|
|
|
|
"XF86MonBrightnessDown" = "exec ${pkgs.light}/bin/light -U 5";
|
|
|
|
"XF86MonBrightnessUp" = "exec ${pkgs.light}/bin/light -A 5";
|
|
|
|
# volume
|
|
|
|
"XF86AudioRaiseVolume" = "exec '${pkgs.pulseaudio}/bin/pactl set-sink-volume @DEFAULT_SINK@ +1%'";
|
|
|
|
"XF86AudioLowerVolume" = "exec '${pkgs.pulseaudio}/bin/pactl set-sink-volume @DEFAULT_SINK@ -1%'";
|
|
|
|
"XF86AudioMute" = "exec '${pkgs.pulseaudio}/bin/pactl set-sink-mute @DEFAULT_SINK@ toggle'";
|
|
|
|
|
|
|
|
# custom pause mode similar to typical system shutdown menus
|
|
|
|
"${modifier}+F12" = "mode pause-break";
|
|
|
|
};
|
|
|
|
menu = "${pkgs.nwg-launchers}/bin/nwggrid -client";
|
|
|
|
|
|
|
|
# use foot as default terminal
|
2024-05-18 16:24:54 +02:00
|
|
|
terminal = "${pkgs.foot}/bin/foot";
|
2024-05-18 15:03:55 +02:00
|
|
|
assigns = {
|
|
|
|
"main" = [{app_id = "firefox";}];
|
|
|
|
"term" = [{app_id = "foot-startup";}];
|
2024-06-28 11:32:52 +02:00
|
|
|
"msg" = [
|
|
|
|
{title = "\\[Locked\\] - KeePassXC$";}
|
|
|
|
{app_id = "thunderbird";}
|
2024-06-28 11:37:09 +02:00
|
|
|
{app_id = "discord";}
|
2024-06-28 11:52:01 +02:00
|
|
|
{app_id = "Element";}
|
2024-06-28 11:32:52 +02:00
|
|
|
];
|
2024-06-28 11:37:09 +02:00
|
|
|
"music" = [{app_id = "org.rncbc.qpwgraph";}];
|
2024-03-10 10:55:16 +01:00
|
|
|
};
|
2024-05-18 15:03:55 +02:00
|
|
|
bars = [];
|
|
|
|
|
|
|
|
modes = {
|
|
|
|
pause-break = {
|
|
|
|
e = "exec --no-startup-id swaymsg exit, mode default";
|
|
|
|
s = "exec --no-startup-id ${pkgs.dash}/bin/dash -c '${pkgs.swaylock}/bin/swaylock & systemctl suspend-then-hibernate', mode default";
|
|
|
|
r = "exec --no-startup-id systemctl reboot";
|
|
|
|
End = "exec --no-startup-id systemctl poweroff";
|
|
|
|
Return = "mode default";
|
|
|
|
Escape = "mode default";
|
|
|
|
};
|
|
|
|
};
|
2024-03-10 10:55:16 +01:00
|
|
|
|
2024-05-18 16:24:54 +02:00
|
|
|
startup =
|
|
|
|
[
|
|
|
|
{command = "${dbus-sway-environment}/bin/dbus-sway-environment";}
|
|
|
|
{command = "${pkgs.nwg-launchers}/bin/nwggrid-server -fp";}
|
|
|
|
{command = "${pkgs.keepassxc}/bin/keepassxc";}
|
|
|
|
{command = "${pkgs.foot}/bin/foot -a foot-startup";}
|
|
|
|
{command = "${pkgs.networkmanagerapplet}/bin/nm-applet";}
|
|
|
|
]
|
|
|
|
++ lib.optionals cfg.laptop [
|
|
|
|
{command = "${pkgs.squeekboard}/bin/squeekboard";}
|
|
|
|
{command = "${pkgs.rot8}/bin/rot8 -n 10 -h ${rotate_lisgd}/bin/rotate_lisgd";}
|
|
|
|
{command = "${rotate_lisgd}/bin/rotate_lisgd";}
|
|
|
|
];
|
2024-05-18 15:03:55 +02:00
|
|
|
|
|
|
|
defaultWorkspace = "main";
|
|
|
|
workspaceAutoBackAndForth = true;
|
2024-05-18 16:24:54 +02:00
|
|
|
workspaceOutputAssign = lib.mkIf cfg.laptop [
|
2024-05-18 15:03:55 +02:00
|
|
|
{
|
|
|
|
workspace = "main";
|
|
|
|
output = ["DP-3" "DP-4" "DP-6" "HDMI-A-1" "eDP-1"];
|
|
|
|
}
|
|
|
|
{
|
|
|
|
workspace = "term";
|
|
|
|
output = ["DP-5" "DP-4" "DP-7" "eDP-1"];
|
|
|
|
}
|
|
|
|
{
|
|
|
|
workspace = "msg";
|
|
|
|
output = ["eDP-1"];
|
|
|
|
}
|
|
|
|
{
|
|
|
|
workspace = "music";
|
|
|
|
output = ["eDP-1"];
|
|
|
|
}
|
|
|
|
{
|
|
|
|
workspace = "5";
|
|
|
|
output = ["DP-3" "DP-4" "DP-6" "HDMI-A-1" "eDP-1"];
|
|
|
|
}
|
|
|
|
];
|
2024-03-10 10:55:16 +01:00
|
|
|
};
|
2024-03-15 15:31:32 +01:00
|
|
|
|
2024-05-18 16:24:54 +02:00
|
|
|
extraConfig = lib.mkIf cfg.laptop ''
|
2024-05-18 15:03:55 +02:00
|
|
|
bindswitch --reload --locked lid:on exec "[ $(${pkgs.sway}/bin/swaymsg -t get_outputs | ${pkgs.jq}/bin/jq '. | length') -gt 1 ] && ${pkgs.sway}/bin/swaymsg output eDP-1 disable"
|
|
|
|
bindswitch --reload --locked lid:off output eDP-1 enable
|
|
|
|
'';
|
2024-03-06 23:02:59 +01:00
|
|
|
};
|
2024-07-03 11:19:21 +02:00
|
|
|
|
|
|
|
services.clipman.enable = true;
|
2024-07-03 12:55:39 +02:00
|
|
|
|
|
|
|
programs.swaylock = {
|
|
|
|
enable = true;
|
|
|
|
settings = {
|
|
|
|
color = "313131";
|
|
|
|
indicator-idle-visible = false;
|
|
|
|
indicator-radius = 200;
|
|
|
|
line-color = "00ffee";
|
|
|
|
show-fai8led-attempts = true;
|
|
|
|
};
|
|
|
|
};
|
2024-03-09 20:39:39 +01:00
|
|
|
};
|
2024-03-06 23:02:59 +01:00
|
|
|
}
|