grimm-nixos-laptop/sway/default.nix

224 lines
7.9 KiB
Nix
Raw Normal View History

2024-04-30 22:04:17 +02:00
{ inputs, system, pkgs, config, lib, ... }:
let
searchclip = pkgs.writeShellScriptBin "searchclip" ''
xdg-open https://www.google.com/search?q=$(wl-paste -p | urlencode)
browser=$(xdg-settings get default-web-browser | sed "s/\.desktop//")
swaymsg [app_id="$browser" urgent="newest"] focus
'';
in
{
2024-04-10 16:51:28 +02:00
environment.systemPackages = with pkgs; [
alacritty
rmenu
grim
slurp
brightnessctl
wl-clipboard
swaymux
qt6ct
swaynotificationcenter
2024-04-30 22:04:17 +02:00
searchclip
2024-04-10 16:51:28 +02:00
];
grimmShared.sway = {
enable = true;
bar = {
2024-03-26 14:18:33 +01:00
enable = true;
2024-04-10 16:51:28 +02:00
config = ./bar/config;
style = ./bar/style.css;
};
2024-03-26 14:18:33 +01:00
2024-04-30 22:04:17 +02:00
config = with pkgs; let
inherit (lib) getExe;
in {
2024-03-24 16:59:47 +01:00
definitions = {
mod = "Mod4";
left = "h";
down = "j";
up = "k";
right = "l";
term = getExe pkgs.alacritty;
2024-04-30 22:04:17 +02:00
menu = "${getExe rmenu} -r drun | xargs swaymsg exec --";
menu_run = "${getExe rmenu} -r run | xargs swaymsg exec --";
2024-03-24 16:59:47 +01:00
primecol = "#8800FF";
accentcol = "#5700a0";
splitcol = "#69507f";
actsplitcol = "#cd97fc";
darkcol = "#202020";
urgentcol = "#9e3c3c";
realwhite = "#C7D3E3";
};
keybinds = {
"$mod+d" = "exec $menu";
2024-04-07 10:33:55 +02:00
"$mod+Shift+d" = "exec $menu_run";
2024-04-30 22:04:17 +02:00
"$mod+Shift+s" = ''exec ${getExe grim} -g "$(${getExe slurp} -d)" - | wl-copy'';
"$mod+Return" = "exec $term --command xonsh";
2024-04-18 21:16:40 +02:00
"$mod+Shift+Return" = "exec $term";
2024-03-24 16:59:47 +01: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'";
2024-04-10 16:51:28 +02:00
# 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";
#
# Workspaces:
#
# Switch to workspace
"$mod+1" = "workspace number 1";
"$mod+2" = "workspace number 2";
"$mod+3" = "workspace number 3";
"$mod+4" = "workspace number 4";
"$mod+5" = "workspace number 5";
"$mod+6" = "workspace number 6";
"$mod+7" = "workspace number 7";
"$mod+8" = "workspace number 8";
"$mod+9" = "workspace number 9";
"$mod+0" = "workspace number 10";
# Move focused container to workspace
"$mod+Shift+1" = "move container to workspace number 1";
"$mod+Shift+2" = "move container to workspace number 2";
"$mod+Shift+3" = "move container to workspace number 3";
"$mod+Shift+4" = "move container to workspace number 4";
"$mod+Shift+5" = "move container to workspace number 5";
"$mod+Shift+6" = "move container to workspace number 6";
"$mod+Shift+7" = "move container to workspace number 7";
"$mod+Shift+8" = "move container to workspace number 8";
"$mod+Shift+9" = "move container to workspace number 9";
"$mod+Shift+0" = "move container to workspace number 10";
# Note: workspaces can have any name you want, not just numbers.
# We just use 1-10 as the default.
#
# 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";
2024-03-24 16:59:47 +01:00
"$mod+Shift+minus" = "move scratchpad";
"$mod+minus" = "scratchpad show";
"$mod+r" = "mode \"resize\"";
2024-03-24 16:59:47 +01:00
2024-04-01 18:32:12 +02:00
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%";
2024-04-01 18:32:12 +02:00
XF86AudioMute = "exec pactl set-sink-mute @DEFAULT_SINK@ toggle";
XF86AudioPlay = "exec playerctl play-pause";
XF86AudioNext = "exec playerctl next";
XF86AudioPrev = "exec playerctl previous";
2024-04-30 22:04:17 +02:00
"$mod+c" = "exec ${getExe swaymux}";
XF86MonBrightnessUp = "exec ${getExe brightnessctl} s 10+%";
XF86MonBrightnessDown = "exec ${getExe brightnessctl} s 10-%";
XF86Explorer = "exec $term --command ${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 || 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)")
deskwhich spotify | xargs gio launch
''; in "exec ${getExe open}"; # for some reason tools = audio media on my keyboard??
2024-03-24 16:59:47 +01:00
};
autolaunch = with pkgs; [
2024-04-10 16:51:28 +02:00
# fixme: absolute paths
2024-03-24 16:59:47 +01:00
"blueman-applet"
"lxqt-policykit-agent"
"otd-daemon"
swaynotificationcenter
2024-04-30 22:04:17 +02:00
# (pkgs.writeShellScriptBin "rmenu-cache-clear" "rm -r $HOME/.cache/rmenu") # invalidate rmenu cache on sway restart
2024-04-18 21:16:40 +02:00
"dbus-update-activation-environment"
2024-03-24 16:59:47 +01:00
];
extraConfig = ''
2024-04-10 16:51:28 +02:00
output * bg ${./wallpapers/switzerland.jpg} fill
2024-04-11 10:56:21 +02:00
2024-04-10 16:51:28 +02:00
floating_modifier $mod normal
2024-03-24 16:59:47 +01:00
2024-04-10 16:51:28 +02:00
input type:keyboard xkb_numlock enabled
include /etc/sway/config.d/*
2024-03-24 16:59:47 +01:00
2024-04-10 16:51:28 +02:00
# Borders, gaps, titlebars, behavior
default_border pixel 3
default_floating_border pixel 3
gaps inner 5
titlebar_padding 5 5
2024-03-24 16:59:47 +01:00
2024-04-10 16:51:28 +02:00
#5Smart things
smart_gaps on
hide_edge_borders --i3 smart
2024-03-24 16:59:47 +01:00
2024-04-10 16:51:28 +02:00
input * {
xkb_layout "de"
2024-04-21 11:25:35 +02:00
dwt disabled
2024-04-10 16:51:28 +02:00
}
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-04-11 10:56:21 +02:00
for_window [app_id="lxqt-policykit-agent"] floating enable;
2024-04-10 16:51:28 +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-04-10 16:42:11 +02:00
};
2024-03-24 16:59:47 +01:00
};
}