flake/users/guanranwang/home-manager/applications/sway/default.nix

129 lines
4.3 KiB
Nix
Raw Normal View History

2023-10-10 07:25:31 +00:00
{
config,
pkgs,
2023-11-04 12:52:55 +00:00
lib,
...
}: {
imports = [
2023-12-18 19:06:50 +00:00
../common/wayland.nix
../common/wm.nix
2023-12-08 15:44:35 +00:00
../cliphist
2023-11-28 05:40:22 +00:00
../dunst
../rofi
../swayidle
../swaylock
../udiskie
../waybar
];
2023-11-04 12:52:55 +00:00
home.sessionVariables = {
2023-11-14 03:22:17 +00:00
GTK_IM_MODULE = lib.mkForce "wayland"; # use text-input-v3
2023-11-04 12:52:55 +00:00
};
2023-10-10 07:25:31 +00:00
wayland.windowManager.sway = {
enable = true;
2023-12-08 15:44:35 +00:00
extraOptions = ["--unsupported-gpu" "-Dnoscanout"];
2023-10-10 07:25:31 +00:00
wrapperFeatures.gtk = true;
2023-12-08 15:44:35 +00:00
systemd.xdgAutostart = true;
2023-10-10 07:25:31 +00:00
config = {
### Default Applications
2023-12-16 14:48:27 +00:00
terminal = lib.getExe pkgs.alacritty;
menu = lib.getExe config.programs.rofi.package;
2023-10-10 07:25:31 +00:00
### Visuals
2023-12-30 16:18:02 +00:00
output."*".bg = "~/.local/share/backgrounds/Minato-Aqua-Dark.png fill";
window.titlebar = false;
gaps.inner = 4;
gaps.outer = 4;
2023-12-08 15:44:35 +00:00
bars = [
{
2023-12-16 14:48:27 +00:00
command = lib.getExe pkgs.waybar;
2023-12-08 15:44:35 +00:00
}
#{
# statusCommand = "${lib.getExe pkgs.i3status-rust} $HOME/.config/i3status-rust/config-default.toml";
# position = "top";
#}
];
2023-10-10 07:25:31 +00:00
### Inputs
2023-12-30 16:18:02 +00:00
input."*" = {
accel_profile = "flat";
natural_scroll = "enabled";
2023-10-10 07:25:31 +00:00
2023-12-30 16:18:02 +00:00
# touchpad
tap = "enabled";
drag = "enabled";
dwt = "disabled";
2023-10-10 07:25:31 +00:00
};
### Keybinds
modifier = "Mod4";
modes = {};
keybindings = let
2023-12-02 10:42:59 +00:00
inherit (config.wayland.windowManager.sway.config) modifier;
2023-12-08 15:44:35 +00:00
inherit (config.wayland.windowManager.sway.config) terminal;
inherit (config.wayland.windowManager.sway.config) menu;
setBrightness = "/home/guanranwang/.local/bin/wrapped-brightnessctl";
setVolume = "/home/guanranwang/.local/bin/wrapped-pamixer";
2023-12-05 07:48:54 +00:00
screenshot = "/home/guanranwang/.local/bin/screenshot";
2023-12-30 15:42:09 +00:00
in
{
### Sway itself
# Window
"${modifier}+s" = "split toggle";
"${modifier}+v" = "floating toggle";
2023-12-30 16:18:02 +00:00
"${modifier}+f" = "fullscreen toggle";
2023-12-30 15:42:09 +00:00
"${modifier}+q" = "kill";
2023-12-30 16:18:02 +00:00
"${modifier}+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'";
2023-10-10 07:25:31 +00:00
2023-12-30 15:42:09 +00:00
# Move around
"${modifier}+h" = "focus left";
"${modifier}+j" = "focus down";
"${modifier}+k" = "focus up";
"${modifier}+l" = "focus right";
2023-10-10 07:25:31 +00:00
2023-12-30 15:42:09 +00:00
### Execute other stuff
# Launch applications
"${modifier}+Return" = "exec ${terminal}";
"${modifier}+w" = "exec ${pkgs.xdg-utils}/bin/xdg-open http:";
"${modifier}+e" = "exec ${pkgs.xdg-utils}/bin/xdg-open ~";
2023-10-10 07:25:31 +00:00
2023-12-30 15:42:09 +00:00
# Rofi
"${modifier}+d" = "exec ${menu} -show drun -show-icons -icon-theme ${config.gtk.iconTheme.name}";
"${modifier}+Shift+d" = "exec ${lib.getExe pkgs.cliphist} list | ${menu} -dmenu | ${lib.getExe pkgs.cliphist} decode | ${pkgs.wl-clipboard}/bin/wl-copy";
"${modifier}+Shift+l" = ''exec ${menu} -modi "power-menu:rofi-power-menu --confirm=reboot/shutdown" -show power-menu'';
2023-10-10 07:25:31 +00:00
2023-12-30 15:42:09 +00:00
# Screenshot
"${modifier}+Shift+s" = "exec ${screenshot} region";
"Print" = "exec ${screenshot} fullscreen";
"Print+Control" = "exec ${screenshot} swappy";
2023-10-10 07:25:31 +00:00
2023-12-30 15:42:09 +00:00
# Fn keys
"XF86MonBrightnessUp" = "exec ${setBrightness} up";
"XF86MonBrightnessDown" = "exec ${setBrightness} down";
"XF86AudioRaiseVolume" = "exec ${setVolume} up";
"XF86AudioLowerVolume" = "exec ${setVolume} down";
"XF86AudioMute" = "exec ${setVolume} mute";
"XF86AudioPlay" = "exec ${lib.getExe pkgs.playerctl} play";
"XF86AudioPause" = "exec ${lib.getExe pkgs.playerctl} pause";
"XF86AudioPrev" = "exec ${lib.getExe pkgs.playerctl} previous";
"XF86AudioNext" = "exec ${lib.getExe pkgs.playerctl} next";
"XF86AudioStop" = "exec ${lib.getExe pkgs.playerctl} stop";
"XF86AudioMedia" = "exec ${lib.getExe pkgs.playerctl} play-pause";
}
//
# workspace binds
builtins.listToAttrs (builtins.concatMap (x: [
{
name = "${modifier}+${x}";
value = "workspace ${x}";
}
{
name = "${modifier}+Shift+${x}";
value = "move container to workspace ${x}";
}
]) (builtins.genList (x: toString (x + 1)) 9));
2023-10-10 07:25:31 +00:00
};
};
}