1{
2 config,
3 nixosConfig,
4 pkgs,
5 lib,
6 tlib,
7 ...
8}:
9{
10 imports = [
11 ../wayland
12 ../swaylock
13 # ../swayidle
14 ../wlsunset
15 ../mako
16 ../tofi
17 # ./swayidle.nix
18 ];
19
20 stylix.targets.sway.enable = true;
21 wayland.windowManager = {
22 sway =
23 let
24 inherit (tlib) pkgBin;
25 in
26 {
27 enable = true;
28 wrapperFeatures.gtk = true;
29 systemd.variables = [ "--all" ];
30 config = {
31 bars = [ ];
32 window = {
33 border = 0;
34 titlebar = false;
35 };
36 menu = "${config.programs.tofi.package}/bin/tofi-drun";
37 modifier = "Mod4";
38 terminal = config.settings.terminal.binary;
39 startup = [
40 { command = "mkdir -p ${config.home.homeDirectory}/shots"; }
41 ];
42 keybindings =
43 let
44 mod = config.wayland.windowManager.sway.config.modifier;
45
46 cat = pkgs.coreutils + "/bin/cat";
47 grim = pkgBin pkgs.grim;
48 slurp = pkgBin pkgs.slurp;
49 pactl = pkgs.pulseaudio + "/bin/pactl";
50 playerctl = pkgBin pkgs.playerctl;
51 wf-recorder = pkgBin pkgs.wf-recorder;
52 wl-copy = pkgs.wl-clipboard + "/bin/wl-copy";
53 wlogout = pkgBin pkgs.wlogout;
54 light = pkgBin pkgs.light;
55
56 shotFile = config.home.homeDirectory + "/shots/shot_$(date '+%Y_%m_%d_%H_%M')";
57 shotDir = config.home.homeDirectory + "/shots";
58 in
59 lib.mkOptionDefault {
60 "${mod}+d" = "exec ${config.wayland.windowManager.sway.config.menu}";
61 "${mod}+Return" = "exec ${config.wayland.windowManager.sway.config.terminal}";
62 "${mod}+Escape" = "exec ${wlogout} -p layer-shell";
63 "${mod}+q" = "kill";
64 "${mod}+Shift+e" = "exit";
65 "${mod}+Shift+r" = "reload";
66 # screenshot and copy it to clipboard
67 "Mod1+s" = ''
68 exec export SFILE="${shotFile}.png" && mkdir -p ${shotDir} && ${grim} "$SFILE" && ${cat} "$SFILE" | ${wl-copy} -t image/png
69 '';
70 # save selected area as a picture and copy it to clipboard
71 "Mod1+Shift+s" = ''
72 exec export SFILE="${shotFile}.png" && mkdir -p ${shotDir} && ${grim} -g "$(${slurp})" "$SFILE" && ${cat} "$SFILE" | ${wl-copy} -t image/png
73 '';
74 # record screen
75 "Mod1+r" =
76 ''exec mkdir -p ${shotDir} && ${wf-recorder} --audio-backend=pipewire --audio=alsa_output.pci-0000_09_00.4.pro-output-0.monitor -f "${shotFile}.mp4"'';
77 # record an area
78 "Mod1+Shift+r" =
79 ''exec mkdir -p ${shotDir} && ${wf-recorder} --audio-backend=pipewire --audio=alsa_output.pci-0000_09_00.4.pro-output-0.monitor -g "$(${slurp})" -f "${shotFile}.mp4"'';
80 # stop recording
81 "Mod1+c" = "exec pkill -INT wf-recorder";
82 "XF86AudioRaiseVolume" = "exec ${pactl} set-sink-volume 0 +5%";
83 "XF86AudioLowerVolume" = "exec ${pactl} set-sink-volume 0 -5%";
84 "XF86AudioMute" = "exec ${pactl} set-sink-mute 0 toggle";
85 "XF86AudioPlay" = "exec ${playerctl} play-pause";
86 "XF86AudioPrev" = "exec ${playerctl} previous";
87 "XF86AudioNext" = "exec ${playerctl} next";
88 "XF86AudioStop" = "exec ${playerctl} stop";
89 "XF86MonBrightnessUp" = "exec ${light} -T 1.4";
90 "XF86MonBrightnessDown" = "exec ${light} -T 0.72";
91 };
92 input = {
93 "13364:832:Keychron_Keychron_V4_Keyboard" = {
94 xkb_layout = nixosConfig.services.xserver.xkb.layout;
95 };
96 "1:1:AT_Translated_Set_2_keyboard" = {
97 xkb_layout = "tr";
98 };
99 "type:pointer" = {
100 accel_profile = "flat";
101 };
102 "type:touchpad" = {
103 accel_profile = "adaptive";
104 tap = "enabled";
105 scroll_method = "two_finger";
106 dwt = "enabled";
107 events = "disabled_on_external_mouse";
108 };
109 };
110 output = {
111 "*" = {
112 bg = "${config.stylix.image} fill";
113 };
114 "eDP-1" = {
115 scale = "2";
116 adaptive_sync = "on";
117 };
118 "DP-1" = {
119 mode = "1920x1080@165.009Hz";
120 };
121 "HDMI-A-2" = {
122 mode = "1920x1080@74.973Hz";
123 };
124 };
125 };
126 };
127 };
128}