nix-dotfiles/snippets/sway.nix
2024-12-17 21:56:38 -05:00

125 lines
4.6 KiB
Nix

{ lib, pkgs, config, ... }@inputs:
let
extra = ../extra;
scripts = ../scripts;
dynscreenshot = pkgs.writeShellScript "dynscreenshot"
(builtins.readFile "${scripts}/dynscreenshot.sh");
changebrightness = pkgs.writeShellScript "changebrightness"
(builtins.readFile "${scripts}/changebrightness.sh");
mod = "Mod4";
shutdownMenu = pkgs.writeShellScript "shutdownmenu"
(builtins.readFile "${scripts}/shutdownmenu.sh");
backgroundImage = "${extra}/kuwaitboat.jpg";
in rec {
wayland.windowManager.sway = {
enable = true;
config = rec {
terminal = "${pkgs.lib.getExe inputs.config.defaultPrograms.terminal}";
modifier = mod;
fonts = {
names = [ "Inter" ];
style = "Regular";
size = 12.0;
};
input = {
"type:touchpad" = {
natural_scroll = "disabled";
dwt = "disabled";
click_method = "clickfinger";
scroll_factor = "0.5";
};
"type:keyboard" = {
xkb_layout = "ca,ca";
xkb_variant = ",eng";
};
};
window = {
border = 2;
titlebar = true;
};
keybindings = let
screenshotPath =
"Pictures/Screenshots/screenshot`date +%Y%m%d%H%M%S`.png";
in lib.mkOptionDefault ({ # Screenshot keybinds
"Print" =
"exec grim - | wl-copy && wl-paste > ${screenshotPath}"; # Take screenshot of whole screen, save it, and copy it to clipboard
"Shift+Print" = ''
exec swaymsg -t get_tree | jq -r '.. | select(.focused?) | .rect | "\(.x),\(.y) \(.width)x\(.height)"' | grim -g - | wl-copy && wl-paste > ${screenshotPath}''; # Take screenshot of current window, save it, and copy it to clipboard
"Ctrl+Print" =
"exec grim -g \"`slurp`\" - | wl-copy && wl-paste > ${screenshotPath}";
} // rec { # Function Media Keys
XF86MonBrightnessUp = "exec bash ${changebrightness} 1";
XF86MonBrightnessDown = "exec bash ${changebrightness} -1";
XF86AudioMute = "exec wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle";
"${mod}+XF86AudioMute" =
"exec wpctl set-mute @DEFAULT_AUDIO_SOURCE@ toggle";
XF86AudioRaiseVolume = "exec wpctl set-volume @DEFAULT_AUDIO_SINK@ 0.05+";
XF86AudioLowerVolume = "exec wpctl set-volume @DEFAULT_AUDIO_SINK@ 0.05-";
"${mod}+XF86AudioRaiseVolume" =
"exec wpctl set-volume @DEFAULT_AUDIO_SOURCE@ 0.05+";
"${mod}+XF86AudioLowerVolume" =
"exec wpctl set-volume @DEFAULT_AUDIO_SOURCE@ 0.05-";
"${mod}+Shift+e" = null;
XF86AudioMedia =
"dunstctl set-paused toggle; dunstify -a 'dunst_mute_key' -u low -h string:x-dunst-stack-tag:dunst_mute_key 'Notifications mute toggled'";
XF86PowerOff =
"exec DMENU_COMMAND='rofi -dmenu -prompt=\"Sélectionnez :\"' bash ${shutdownMenu}";
"${mod}+Pause" = XF86PowerOff;
} // {
"${mod}+space" = ''input "*" xkb_switch_layout next'';
"${mod}+Shift+l" = "exec swaylock -f";
"${mod}+Home" = "move workspace to output left";
"${mod}+End" = "move workspace to output right";
} // { });
# menu = "j4-dmenu-desktop --no-generic --term=${
# terminal
# } --dmenu='${dmenuCommand}'";
menu = "${pkgs.lib.getExe config.programs.rofi.package} -modes \"drun,run\" -show-icons -show drun";
focus.followMouse = false;
};
extraConfig = ''
output 'eDP-1' scale 1.50
'' + # Fractional scaling to 1.50
''
exec gammastep-indicator
'' + # gammastep-indicator enables red shift
''
exec dunst
'' + # Enable notifications
''
exec "activate-linux -c 0.5-0.5-0.5-0.5"
'' + # Enable Activate Linux
''
bindgesture swipe:4:up focus parent
bindgesture swipe:4:left workspace prev
bindgesture swipe:4:right workspace next
bindgesture swipe:3:up focus up
bindgesture swipe:3:down focus down
bindgesture swipe:3:left focus left
bindgesture swipe:3:right focus right
'' + # Multi-touch touchpad gestures
''
exec swaybg -i ${backgroundImage}
'' + # Background image
''
focus_on_window_activation focus
'' + # Focus on window activation lol
''
set $laptop eDP-1
bindswitch --reload --locked lid:on output $laptop disable
bindswitch --reload --locked lid:off output $laptop enable
'' + # Clamshell mode
"";
};
programs.rofi = {
enable = true;
font = "Inter 12";
package = pkgs.rofi-wayland;
theme = "android_notification";
};
home.packages = with pkgs; [ swaybg bemenu j4-dmenu-desktop ];
}