btw i use nix
1{
2 pkgs,
3 config,
4 lib,
5 ...
6}@inputs:
7
8let
9 i3-workspace-history =
10 inputs.i3-workspace-history.packages.${pkgs.stdenv.hostPlatform.system}.default;
11 replacements = {
12 wm = "sway";
13 wmmsg = "swaymsg";
14 rofi = "wofi";
15 app_id = "app_id";
16 bar_extra = ''
17 icon_theme Papirus
18 '';
19 locked = "--locked";
20 polkit_gnome = "${pkgs.polkit_gnome}";
21 locker = "swaylock -f -i $WALLPAPER";
22 enable_output = "swaymsg output $laptop_output enable";
23 disable_output = "swaymsg output $laptop_output disable";
24 drun = "wofi -i --show drun --allow-images -a";
25 dmenu = "wofi -d -i -p";
26 displays = "wdisplays";
27 bar = "swaybar";
28 notification_deamon = "dunst";
29 i3_workspace_history = "${i3-workspace-history}/bin/i3-workspace-history";
30 i3_workspace_history_args = "-sway";
31 };
32 util = import ./util.nix { inherit pkgs lib; };
33 cfg = config.custom.gui.sway;
34in
35{
36 options.custom.gui.sway.enable = lib.mkEnableOption "sway";
37
38 config = lib.mkIf cfg.enable {
39 home.packages = with pkgs; [
40 i3-workspace-history
41 # https://todo.sr.ht/~scoopta/wofi/73
42 (stdenv.mkDerivation {
43 name = "xterm-compat";
44 buildInputs = [ pkgs.bash ];
45 dontUnpack = true;
46 installPhase = ''
47 mkdir -p $out/bin
48 cat > $out/bin/xterm <<EOF
49 #!/usr/bin/env bash
50
51 exec \$TERMINAL "\$@"
52 EOF
53 chmod +x $out/bin/xterm
54 '';
55 })
56 ];
57
58 home.file.".zprofile".text = ''
59 # Autostart sway at login on TTY 1
60 if [ -z "''${DISPLAY}" ] && [ "''${XDG_VTNR}" -eq 1 ]; then
61 source $HOME/.nix-profile/etc/profile.d/hm-session-vars.sh
62 export QT_QPA_PLATFORM="wayland"
63 export SDL_VIDEODRIVER="wayland"
64 export MOZ_ENABLE_WAYLAND=1
65 export MOZ_DBUS_REMOTE=1
66 export QT_STYLE_OVERRIDE="Fusion"
67 export WLR_NO_HARDWARE_CURSORS=1
68 export NIXOS_OZONE_WL=1
69
70 # for intellij
71 export _JAVA_AWT_WM_NONREPARENTING=1
72
73 # for screensharing
74 export XDG_SESSION_TYPE="wayland"
75 export XDG_CURRENT_DESKTOP="sway"
76
77 exec sway -d
78 fi
79 '';
80
81 xdg.configFile =
82 let
83 entries = {
84 "fusuma/config.yml".source = ./fusuma.yml;
85 "kanshi/config".source = ./kanshi;
86 "dunst/dunstrc".source = ./dunst;
87 "swaylock/config".source = ./swaylock;
88 "wofi/style.css".source = ./wofi.css;
89 "swappy/config".text = ''
90 [Default]
91 save_dir=$XDG_PICTURES_DIR/capture/
92 save_filename_format=screenshot_%Y-%m-%dT%H:%M:%S%z.png
93 '';
94 "sway/config".text =
95 let
96 wmFilenames = util.listFilesInDir ./wm/config.d;
97 in
98 let
99 swayFilenames = util.listFilesInDir ./wm/sway;
100 in
101 (util.concatFilesReplace ([ ./wm/config ] ++ wmFilenames ++ swayFilenames) replacements);
102 };
103 in
104 (util.inDirReplace ./wm/scripts "sway/scripts" replacements) // entries;
105
106 services.gammastep = {
107 enable = true;
108 provider = "geoclue2";
109 temperature.day = 6500;
110 };
111 systemd.user.services.gammastep.Service.ExecStart =
112 lib.mkForce "${pkgs.gammastep}/bin/gammastep -r";
113 };
114}