ark/users/modules/sway/default.nix

120 lines
4.1 KiB
Nix
Raw Normal View History

2022-11-27 01:04:43 +03:00
{
config,
nixosConfig,
pkgs,
lib,
tlib,
...
}: {
imports = [
../wayland
../swaylock
../wlsunset
../dunst
../rofi
# ./swayidle.nix
];
wayland.windowManager = {
sway = let
mkRofiCmd = args: "${config.programs.rofi.package}/bin/rofi ${lib.concatStringsSep " " args} | ${pkgs.sway}/bin/swaymsg --";
inherit (tlib) pkgBin;
in {
enable = true;
extraSessionCommands = ''
export QT_QPA_PLATFORM=wayland
'';
wrapperFeatures.gtk = true;
extraConfig = ''
exec dbus-update-activation-environment --systemd WAYLAND_DISPLAY XDG_CURRENT_DESKTOP=sway
exec xprop -root -f _XWAYLAND_GLOBAL_OUTPUT_SCALE 32c -set _XWAYLAND_GLOBAL_OUTPUT_SCALE 2
'';
config = {
bars = [];
gaps.smartBorders = "on";
2023-09-10 21:40:39 +03:00
menu = mkRofiCmd [
"-show"
"drun"
];
2022-11-27 01:04:43 +03:00
modifier = "Mod4";
terminal = config.settings.terminal.binary;
keybindings = let
mod = config.wayland.windowManager.sway.config.modifier;
cat = pkgs.coreutils + "/bin/cat";
grim = pkgBin pkgs.grim;
slurp = pkgBin pkgs.slurp;
pactl = pkgs.pulseaudio + "/bin/pactl";
playerctl = pkgBin pkgs.playerctl;
wf-recorder = pkgBin pkgs.wf-recorder;
wl-copy = pkgs.wl-clipboard + "/bin/wl-copy";
wlogout = pkgBin pkgs.wlogout;
light = pkgBin pkgs.light;
shotFile = config.home.homeDirectory + "/shots/shot_$(date '+%Y_%m_%d_%H_%M')";
shotDir = config.home.homeDirectory + "/shots";
in
lib.mkOptionDefault
{
"${mod}+Escape" = "exec ${wlogout} -p layer-shell";
"${mod}+q" = "kill";
"${mod}+Shift+e" = "exit";
"${mod}+Shift+r" = "reload";
# Screenshot and copy it to clipboard
"Mod1+s" = ''
exec export SFILE="${shotFile}.png" && mkdir -p ${shotDir} && ${grim} "$SFILE" && ${cat} "$SFILE" | ${wl-copy} -t image/png
'';
# Save selected area as a picture and copy it to clipboard
"Mod1+Shift+s" = ''
exec export SFILE="${shotFile}.png" && mkdir -p ${shotDir} && ${grim} -g "$(${slurp})" "$SFILE" && ${cat} "$SFILE" | ${wl-copy} -t image/png
'';
# Record screen
2023-11-24 17:02:44 +03:00
"Mod1+r" = ''exec mkdir -p ${shotDir} && ${wf-recorder} -x yuv420p -f "${shotFile}.mp4"'';
2022-11-27 01:04:43 +03:00
# Record an area
2023-11-24 17:02:44 +03:00
"Mod1+Shift+r" = ''exec mkdir -p ${shotDir} && ${wf-recorder} -x yuv420p -g "$(${slurp})" -f "${shotFile}.mp4"'';
2022-11-27 01:04:43 +03:00
# Stop recording
"Mod1+c" = "exec pkill -INT wf-recorder";
"XF86AudioRaiseVolume" = "exec ${pactl} set-sink-volume 0 +5%";
"XF86AudioLowerVolume" = "exec ${pactl} set-sink-volume 0 -5%";
"XF86AudioMute" = "exec ${pactl} set-sink-mute 0 toggle";
"XF86AudioPlay" = "exec ${playerctl} play-pause";
"XF86AudioPrev" = "exec ${playerctl} previous";
"XF86AudioNext" = "exec ${playerctl} next";
"XF86AudioStop" = "exec ${playerctl} stop";
"XF86MonBrightnessUp" = "exec ${light} -T 1.4";
"XF86MonBrightnessDown" = "exec ${light} -T 0.72";
};
input = {
2023-05-11 14:14:41 +03:00
"13364:832:Keychron_Keychron_V4_Keyboard" = {
2022-11-27 01:04:43 +03:00
xkb_layout = nixosConfig.services.xserver.layout;
2023-01-25 16:57:18 +03:00
};
2023-05-11 14:14:41 +03:00
"1:1:AT_Translated_Set_2_keyboard" = {
xkb_layout = "tr";
};
2023-01-25 16:57:18 +03:00
"type:pointer" = {
2022-11-27 01:04:43 +03:00
accel_profile = "flat";
};
2023-01-25 16:57:18 +03:00
"type:touchpad" = {
accel_profile = "adaptive";
tap = "enabled";
2023-02-25 00:44:31 +03:00
scroll_method = "two_finger";
2023-01-25 16:57:18 +03:00
dwt = "enabled";
events = "disabled_on_external_mouse";
};
2022-11-27 01:04:43 +03:00
};
output = {
"*" = {
2023-03-24 15:10:42 +03:00
bg = "${config.stylix.image} fill";
2022-11-27 01:04:43 +03:00
};
"eDP-1" = {
scale = "2";
2023-10-08 09:51:05 +03:00
adaptive_sync = "on";
2022-11-27 01:04:43 +03:00
};
"HDMI-A-1" = {
2024-01-14 22:05:39 +03:00
mode = "1920x1080@74.973Hz";
2022-11-27 01:04:43 +03:00
};
};
};
};
};
}