grimm-nixos-laptop/sway/default.nix

219 lines
7.6 KiB
Nix
Raw Normal View History

2024-05-11 22:55:59 +02:00
{ pkgs, lib, ... }:
2024-05-02 15:04:38 +02:00
{
2024-05-07 23:31:41 +02:00
imports = [ ./bar ];
2024-05-05 16:25:16 +02:00
2024-04-10 16:51:28 +02:00
environment.systemPackages = with pkgs; [
rmenu
grim
slurp
brightnessctl
wl-clipboard
swaymux
qt6ct
swaynotificationcenter
2024-04-30 22:04:17 +02:00
searchclip
2024-05-02 14:02:35 +02:00
ydotool
2024-05-05 16:25:16 +02:00
networkmanagerapplet
2024-04-10 16:51:28 +02:00
];
grimmShared.sway = {
enable = true;
2024-05-07 23:31:41 +02:00
config =
let
inherit (lib) getExe;
2024-05-11 22:55:59 +02:00
inherit (pkgs)
rmenu
xdg-terminal-exec
slurp
swaymux
grim
brightnessctl
searchclip
ranger
deskwhich
;
2024-05-07 23:31:41 +02:00
in
{
definitions = {
mod = "Mod4";
left = "h";
down = "j";
up = "k";
right = "l";
menu = "${getExe rmenu} -r drun | xargs swaymsg exec --";
menu_run = "${getExe rmenu} -r run | xargs swaymsg exec --";
primecol = "#8800FF";
accentcol = "#5700a0";
splitcol = "#69507f";
actsplitcol = "#cd97fc";
darkcol = "#202020";
urgentcol = "#9e3c3c";
realwhite = "#C7D3E3";
};
keybinds = {
"$mod+d" = "exec $menu";
"$mod+Shift+d" = "exec $menu_run";
"$mod+Shift+s" = ''exec ${getExe grim} -g "$(${getExe slurp} -d)" - | wl-copy'';
2024-06-13 22:56:30 +02:00
"$mod+Shift+Return" = "exec ${getExe xdg-terminal-exec} xonsh";
"$mod+Return" = "exec ${getExe xdg-terminal-exec}";
2024-05-07 23:31:41 +02:00
"$mod+Shift+q" = "kill";
"$mod+Shift+c" = "reload";
"$mod+Shift+e" = "exec swaynag -t warning -m 'You pressed the exit shortcut. Do you really want to exit sway? This will end your Wayland session.' -B 'Yes, exit sway' 'swaymsg exit'";
# Move your focus around
"$mod+$left" = "focus left";
"$mod+$down" = "focus down";
"$mod+$up" = "focus up";
"$mod+$right" = "focus right";
# Or use $mod+[up|down|left|right]
"$mod+Left" = "focus left";
"$mod+Down" = "focus down";
"$mod+Up" = "focus up";
"$mod+Right" = "focus right";
# Move the focused window with the same, but add Shift
"$mod+Shift+$left" = "move left";
"$mod+Shift+$down" = "move down";
"$mod+Shift+$up" = "move up";
"$mod+Shift+$right" = "move right";
# Ditto, with arrow keys
"$mod+Shift+Left" = "move left";
"$mod+Shift+Down" = "move down";
"$mod+Shift+Up" = "move up";
"$mod+Shift+Right" = "move right";
2024-06-13 22:56:30 +02:00
2024-05-07 23:31:41 +02:00
# Layout stuff:
#
# You can "split" the current object of your focus with
# $mod+b or $mod+v, for horizontal and vertical splits
# respectively.
"$mod+b" = "splith";
"$mod+v" = "splitv";
# Switch the current container between different layout styles
"$mod+s" = "layout stacking";
"$mod+w" = "layout tabbed";
"$mod+e" = "layout toggle split";
# Make the current focus fullscreen
"$mod+f" = "fullscreen";
# Toggle the current focus between tiling and floating mode
"$mod+Shift+space" = "floating toggle";
# Swap focus between the tiling area and the floating area
"$mod+space" = "focus mode_toggle";
# Move focus to the parent container
"$mod+a" = "focus parent";
"$mod+Shift+minus" = "move scratchpad";
"$mod+minus" = "scratchpad show";
"$mod+r" = "mode \"resize\"";
XF86AudioRaiseVolume = "exec pactl set-sink-volume @DEFAULT_SINK@ +5%";
XF86AudioLowerVolume = "exec pactl set-sink-volume @DEFAULT_SINK@ -5%";
"Shift+XF86AudioLowerVolume" = "exec pactl set-source-volume @DEFAULT_SOURCE@ -5%";
"Shift+XF86AudioRaiseVolume" = "exec pactl set-source-volume @DEFAULT_SOURCE@ +5%";
XF86AudioMute = "exec pactl set-sink-mute @DEFAULT_SINK@ toggle";
XF86AudioPlay = "exec playerctl play-pause";
XF86AudioNext = "exec playerctl next";
XF86AudioPrev = "exec playerctl previous";
"$mod+c" = "exec ${getExe swaymux}";
XF86MonBrightnessUp = "exec ${getExe brightnessctl} s 10+%";
XF86MonBrightnessDown = "exec ${getExe brightnessctl} s 10-%";
XF86Explorer = "exec ${getExe xdg-terminal-exec} ${getExe ranger}";
XF86Search = "exec ${getExe searchclip}";
XF86HomePage =
let
open = pkgs.writeShellScriptBin "open_or_switch_browser" ''
browser=$(xdg-settings get default-web-browser | sed "s/\.desktop//")
swaymsg [app_id="$browser"] focus || ${getExe deskwhich} $browser | xargs gio launch
'';
in
"exec ${getExe open}";
XF86Tools =
let
open = pkgs.writeShellScriptBin "open_or_switch_spotify" ''
# FIXME: spotify is being weird
while IFS= read -r pid; do
swaymsg [pid=$pid] focus && exit 0
done <<< $(pgrep spotify -u "$(whoami)")
${getExe deskwhich} spotify | xargs gio launch
'';
in
"exec ${getExe open}"; # for some reason tools = audio media on my keyboard??
XF86Mail =
let
open = pkgs.writeShellScriptBin "open_or_switch_mail" ''
desk=$(xdg-settings get default-url-scheme-handler mailto | sed "s/\.desktop//")
swaymsg [app_id="$desk"] focus || ${getExe deskwhich} $desk | xargs gio launch
'';
in
"exec ${getExe open}";
# XF86Bluetooth = "exec blueman-manager";
2024-06-13 22:56:30 +02:00
} // (let inherit (builtins) toString; in lib.mergeAttrsList (map (n: {
"$mod+${toString n}" = "workspace number ${toString n}";
"$mod+Shift+${toString n}" = "move container to workspace number ${toString n}";
}) (lib.range 0 9)));
2024-05-07 23:31:41 +02:00
autolaunch = with pkgs; [
# fixme: absolute paths
"blueman-applet"
"lxqt-policykit-agent"
"otd-daemon"
swaynotificationcenter
networkmanagerapplet
# (pkgs.writeShellScriptBin "rmenu-cache-clear" "rm -r $HOME/.cache/rmenu") # invalidate rmenu cache on sway restart
"dbus-update-activation-environment"
];
extraConfig = ''
output * bg ${./wallpapers/switzerland.jpg} fill
floating_modifier $mod normal
input type:keyboard xkb_numlock enabled
include /etc/sway/config.d/*
# Borders, gaps, titlebars, behavior
default_border pixel 3
default_floating_border pixel 3
gaps inner 5
titlebar_padding 5 5
#5Smart things
smart_gaps on
hide_edge_borders --i3 smart
input * {
xkb_layout "de"
dwt disabled
}
for_window [app_id="swaymux"] floating enable
for_window [app_id="rmenu"] floating enable
for_window [app_id="firefox.*" title="Picture-in-Picture"] floating enable
2024-05-08 08:31:25 +02:00
for_window [app_id="lxqt-policykit-agent"] floating enable
for_window [title="OpenSSH Authentication Passphrase request"] floating enable
2024-05-07 23:31:41 +02:00
'';
modes.resize.keybinds = {
"$left" = "resize shrink width 10px";
"$down" = "resize grow height 10px";
"$up" = "resize shrink height 10px";
"$right" = "resize grow width 10px";
Left = "resize shrink width 10px";
Down = "resize grow height 10px";
Up = "resize shrink height 10px";
Right = "resize grow width 10px";
Return = "mode \"default\"";
Escape = "mode \"default\"";
};
2024-03-24 16:59:47 +01:00
};
};
}