nixos-config/home-manager/wayland/sway.nix

140 lines
5.4 KiB
Nix
Raw Normal View History

{ pkgs, lib, ... }:
2022-01-06 21:14:02 -05:00
let
2022-05-11 17:18:58 -04:00
modifier = "Mod4";
2022-01-06 21:14:02 -05:00
terminal = "alacritty";
in {
2023-01-07 20:52:23 -05:00
home.packages = with pkgs; [
swayidle
wl-clipboard
wtype
2023-01-07 20:52:23 -05:00
wlroots
grim
slurp
imv
];
2022-01-06 21:14:02 -05:00
wayland.windowManager.sway = {
enable = true;
wrapperFeatures.gtk = true;
config = {
inherit modifier terminal;
2022-09-23 23:33:11 -04:00
menu = "rofi -show drun";
2022-01-06 21:14:02 -05:00
fonts = {
2022-09-23 23:33:11 -04:00
names = [ "JetBrainsMono Nerd Font" ];
2022-01-06 21:14:02 -05:00
style = "Medium";
2022-09-23 23:33:11 -04:00
size = 10.0;
2022-01-06 21:14:02 -05:00
};
bars = [{ command = "waybar"; }];
window.border = 3;
2022-01-06 21:14:02 -05:00
gaps = {
inner = 8;
outer = 0;
2022-01-06 21:14:02 -05:00
};
colors = {
unfocused.border = "#474f6f";
unfocused.background = "#1a1b26";
unfocused.text = "#a9b1d6";
unfocused.indicator = "#474f6f";
unfocused.childBorder = "#474f6f";
2022-01-06 21:14:02 -05:00
focused.border = "#7bc5e4";
focused.background = "#1a1b26";
focused.text = "#a9b1d6";
focused.indicator = "#7bc5e4";
focused.childBorder = "#7bc5e4";
2022-01-06 21:14:02 -05:00
focusedInactive.border = "#787c99";
focusedInactive.background = "#1a1b26";
focusedInactive.text = "#a9b1d6";
focusedInactive.indicator = "#787c99";
focusedInactive.childBorder = "#787c99";
2022-01-06 21:14:02 -05:00
urgent.border = "#d5556f";
urgent.background = "#444b6a";
2022-01-06 21:14:02 -05:00
urgent.text = "#ffffff";
urgent.indicator = "#d5556f";
urgent.childBorder = "#d5556f";
2022-01-06 21:14:02 -05:00
};
2022-01-06 21:14:02 -05:00
startup = map (x: { command = x; }) [
# Make wob channels
2023-01-07 20:52:23 -05:00
''mkfifo $XDG_RUNTIME_DIR/wob_volume.sock && tail -f $XDG_RUNTIME_DIR/wob_volume.sock \
| wob -c ~/.config/wob/volume.ini''
''mkfifo $XDG_RUNTIME_DIR/wob_brightness.sock && tail -f $XDG_RUNTIME_DIR/wob_brightness.sock \
| wob -c ~/.config/wob/brightness.ini''
2022-01-06 21:14:02 -05:00
''swayidle timeout 120 'swaylock -f --grace=180' \
timeout 600 'systemctl suspend' \
before-sleep 'swaylock -f' ''
''export XDG_SESSION_TYPE=wayland''
''export XDG_CURRENT_DESKTOP=sway''
];
keybindings = let
# Volume using pamixer and wob
2023-01-07 20:52:23 -05:00
audio-disp = ''pamixer --get-volume > $XDG_RUNTIME_DIR/wob_volume.sock'';
2022-01-06 21:14:02 -05:00
audio = cmd: "exec pamixer ${cmd} && ${audio-disp}";
# Brightness using brightnessctl and wob
2023-01-07 20:52:23 -05:00
brightness-disp = ''brightnessctl -e -m | cut -d "," -f4 | tr -d "%" > $XDG_RUNTIME_DIR/wob_brightness.sock'';
2022-06-06 17:48:20 -04:00
brightness = x: "exec brightnessctl -e set ${x} && ${brightness-disp}";
# Play controls using playerctl
2022-01-06 21:14:02 -05:00
playerctl = cmd: "exec playerctl ${cmd}";
2022-04-13 17:56:08 -04:00
# Grim screenshot file name
2022-06-16 16:27:36 -04:00
filename = ''~/Pictures/$(date +%Y-%m-%d_%H-%M-%S).png'';
2022-01-06 21:14:02 -05:00
in pkgs.lib.mkOptionDefault {
2022-09-24 22:45:50 -04:00
"${modifier}+Shift+d" = "exec rofi -show run -config ~/.config/rofi/noicons.rasi";
2023-01-03 22:14:05 -05:00
"${modifier}+w" = "exec rofi -show workspace -config ~/.config/rofi/noicons.rasi";
"${modifier}+Shift+w" = "exec rofi -show workspacemove -config ~/.config/rofi/noicons.rasi";
2022-09-23 23:33:11 -04:00
"${modifier}+t" = "layout tabbed";
"${modifier}+Shift+m" = "exec swaylock";
2022-01-06 21:14:02 -05:00
2022-10-08 21:31:02 -04:00
# Emacs Everywhere
2023-08-31 22:29:46 -04:00
"${modifier}+q" = "exec ~/.emacs.d/bin/doom +everywhere";
2022-10-08 21:31:02 -04:00
2022-01-06 21:14:02 -05:00
# Screenshot
2022-04-13 17:56:08 -04:00
"Print" = ''exec grim ${filename}'';
"Shift+Print" = ''exec grim -g "$(slurp)" ${filename}'';
2023-09-21 23:37:09 -04:00
"Mod1+Print" = ''exec grim -g "$(swaymsg -t get_tree | jq -j '.. | \
select(.type?) | select(.focused).rect | "\(.x),\(.y) \(.width)x\(.height)"')" ${filename}'';
2022-01-06 21:14:02 -05:00
# Special XF86 key bindings
"XF86AudioRaiseVolume" = audio "-ui 2";
"XF86AudioLowerVolume" = audio "-ud 2";
"Shift+XF86AudioRaiseVolume" = audio "-ui 2 --allow-boost";
"Shift+XF86AudioLowerVolume" = audio "-ud 2 --allow-boost";
"XF86AudioMute" = ''exec pamixer --toggle-mute'';
"XF86AudioMicMute" = ''exec pactl set-source-mute @DEFAULT_SOURCE@ toggle'';
2022-03-03 09:09:03 -05:00
"XF86MonBrightnessDown" = brightness "4%-";
2022-06-06 19:04:14 -04:00
"XF86MonBrightnessUp" = brightness "4%+";
"XF86AudioPlay" = playerctl "play-pause";
"XF86AudioNext" = playerctl "next";
"XF86AudioPrev" = playerctl "previous";
# Exit
2023-10-27 15:21:44 -04:00
"${modifier}+Shift+e" = ''exec pkill -0 swaynag || \
swaynag -t exit -m "Do you really want to exit?" \
2023-09-21 23:38:42 -04:00
-B "Reboot" "reboot" -B "Shutdown" "poweroff" -b "Exit" "swaymsg exit"'';
# Workspaces
2022-09-23 23:33:11 -04:00
"${modifier}+1" = "workspace 10:browser";
"${modifier}+2" = "workspace 20:terminal";
"${modifier}+3" = "workspace 30:code";
"${modifier}+4" = "workspace 40:files";
"${modifier}+5" = "workspace 50:discord";
"${modifier}+6" = "workspace 60:settings";
"${modifier}+Shift+1" = "move container to workspace 10:browser";
"${modifier}+Shift+2" = "move container to workspace 20:terminal";
"${modifier}+Shift+3" = "move container to workspace 30:code";
"${modifier}+Shift+4" = "move container to workspace 40:files";
"${modifier}+Shift+5" = "move container to workspace 50:discord";
"${modifier}+Shift+6" = "move container to workspace 60:settings";
2022-01-06 21:14:02 -05:00
};
output."*".bg = "${../../assets/background.png} fill";
2022-01-06 21:14:02 -05:00
};
};
}