2022-06-12 15:39:15 +00:00
|
|
|
{
|
|
|
|
config,
|
|
|
|
pkgs,
|
|
|
|
lib,
|
|
|
|
...
|
|
|
|
}: let
|
2022-04-14 07:27:25 +00:00
|
|
|
switch_window = pkgs.writeScript "switchWindow" ''
|
|
|
|
# https://www.reddit.com/r/swaywm/comments/krd0sq/comment/gib6z73/?context=3
|
|
|
|
jq_filter='
|
|
|
|
# descend to workspace or scratchpad
|
|
|
|
.nodes[].nodes[]
|
|
|
|
# save workspace name as .w
|
|
|
|
| {"w": .name} + (
|
|
|
|
if (.nodes|length) > 0 then # workspace
|
|
|
|
[recurse(.nodes[])]
|
|
|
|
else # scratchpad
|
|
|
|
[]
|
|
|
|
end
|
|
|
|
+ .floating_nodes
|
|
|
|
| .[]
|
|
|
|
# select nodes with no children (windows)
|
|
|
|
| select(.nodes==[])
|
|
|
|
)
|
|
|
|
| [
|
|
|
|
"<span size=\"xx-small\">\(.id)</span>",
|
|
|
|
# remove markup and index from workspace name, replace scratch with "[S]"
|
|
|
|
"<span size=\"xx-small\">\(.w | gsub("^[^:]*:|<[^>]*>"; "") | sub("__i3_scratch"; "[S]"))</span>",
|
|
|
|
# get app name (or window class if xwayland)
|
|
|
|
"<span weight=\"bold\">\(if .app_id == null then .window_properties.class else .app_id end)</span>",
|
|
|
|
"<span style=\"italic\">\(.name)</span>"
|
|
|
|
] | @tsv
|
|
|
|
'
|
|
|
|
${pkgs.sway}/bin/swaymsg -t get_tree | ${pkgs.jq}/bin/jq -r "$jq_filter" | ${pkgs.wofi}/bin/wofi -m --insensitive --show dmenu --prompt='Focus a window' | {
|
|
|
|
read -r id name && swaymsg "[con_id=$id]" focus
|
|
|
|
}
|
|
|
|
'';
|
|
|
|
screenshot_then_switch = pkgs.writeScript "screenshotThenSwitch" ''
|
|
|
|
${pkgs.sway-contrib.grimshot}/bin/grimshot "$@"
|
|
|
|
${pkgs.sway}/bin/swaymsg mode default
|
|
|
|
'';
|
2022-06-22 15:13:11 +00:00
|
|
|
bg-full-res = "${pkgs.lotte-art}/2022-06-21-sammythetanuki-lotteplushpride.jxl";
|
2022-06-22 19:11:28 +00:00
|
|
|
bg-1440p = pkgs.stdenvNoCC.mkDerivation {
|
2022-06-22 15:13:11 +00:00
|
|
|
name = "wayland-background-1440p.png";
|
|
|
|
nativeBuildInputs = [pkgs.imagemagick];
|
2022-06-22 19:11:28 +00:00
|
|
|
src = pkgs.emptyDirectory;
|
2022-06-22 15:13:11 +00:00
|
|
|
buildPhase = ''
|
|
|
|
convert ${bg-full-res} -resize 2560x1440 $out
|
|
|
|
'';
|
|
|
|
installPhase = "true";
|
|
|
|
};
|
2022-06-22 19:11:28 +00:00
|
|
|
bg-1080p = pkgs.stdenvNoCC.mkDerivation {
|
2022-06-22 15:13:11 +00:00
|
|
|
name = "wayland-background-1080p.png";
|
|
|
|
nativeBuildInputs = [pkgs.imagemagick];
|
2022-06-22 19:11:28 +00:00
|
|
|
src = pkgs.emptyDirectory;
|
2022-06-22 15:13:11 +00:00
|
|
|
buildPhase = ''
|
|
|
|
convert ${bg-full-res} -resize 1920x1080 $out
|
|
|
|
'';
|
|
|
|
installPhase = "true";
|
|
|
|
};
|
2022-07-06 06:59:56 +00:00
|
|
|
# bash script to let dbus know about important env variables and
|
|
|
|
# propogate them to relevent services run at the end of sway config
|
|
|
|
# see
|
|
|
|
# https://github.com/emersion/xdg-desktop-portal-wlr/wiki/"It-doesn't-work"-Troubleshooting-Checklist
|
2022-07-06 10:50:25 +00:00
|
|
|
# note: this is pretty much the same as /etc/sway/config.d/nixos.conf but also restarts
|
2022-07-06 06:59:56 +00:00
|
|
|
# some user services to make sure they have the correct environment variables
|
|
|
|
dbus-sway-environment = pkgs.writeTextFile {
|
|
|
|
name = "dbus-sway-environment";
|
|
|
|
destination = "/bin/dbus-sway-environment";
|
|
|
|
executable = true;
|
|
|
|
|
|
|
|
text = ''
|
|
|
|
${pkgs.dbus}/bin/dbus-update-activation-environment --systemd WAYLAND_DISPLAY XDG_CURRENT_DESKTOP=sway
|
|
|
|
${pkgs.systemd}/bin/systemctl --user stop pipewire pipewire-media-session xdg-desktop-portal xdg-desktop-portal-wlr
|
|
|
|
${pkgs.systemd}/bin/systemctl --user start pipewire pipewire-media-session xdg-desktop-portal xdg-desktop-portal-wlr
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
# currently, there is some friction between sway and gtk:
|
|
|
|
# https://github.com/swaywm/sway/wiki/GTK-3-settings-on-Wayland
|
|
|
|
# the suggested way to set gtk settings is with gsettings
|
|
|
|
# for gsettings to work, we need to tell it where the schemas are
|
|
|
|
# using the XDG_DATA_DIR environment variable
|
|
|
|
# run at the end of sway config
|
|
|
|
configure-gtk = pkgs.writeTextFile {
|
2022-07-06 10:50:25 +00:00
|
|
|
name = "configure-gtk";
|
|
|
|
destination = "/bin/configure-gtk";
|
|
|
|
executable = true;
|
|
|
|
text = let
|
|
|
|
schema = pkgs.gsettings-desktop-schemas;
|
|
|
|
datadir = "${schema}/share/gsettings-schemas/${schema.name}";
|
|
|
|
in ''
|
|
|
|
export XDG_DATA_DIRS=${datadir}:$XDG_DATA_DIRS
|
|
|
|
gnome_schema=org.gnome.desktop.interface
|
|
|
|
${pkgs.glib}/bin/gsettings set $gnome_schema gtk-theme 'Breeze-Dark'
|
|
|
|
'';
|
2022-07-06 06:59:56 +00:00
|
|
|
};
|
2022-06-12 15:39:15 +00:00
|
|
|
in {
|
2022-03-06 09:21:11 +00:00
|
|
|
imports = [
|
|
|
|
./wl-clipboard.nix
|
2022-03-06 09:29:25 +00:00
|
|
|
./mako.nix
|
2022-03-06 09:43:01 +00:00
|
|
|
./swayidle.nix
|
2022-03-06 09:21:11 +00:00
|
|
|
];
|
2022-03-23 21:11:53 +00:00
|
|
|
home.file.".config/wofi/config".text = ''
|
2022-03-23 21:07:18 +00:00
|
|
|
allow_markup = true
|
|
|
|
dmenu-parse_action = true
|
|
|
|
'';
|
2022-01-18 13:12:43 +00:00
|
|
|
wayland.windowManager.sway = {
|
2022-01-18 13:16:40 +00:00
|
|
|
enable = true;
|
2022-01-18 13:12:43 +00:00
|
|
|
config = {
|
2022-01-18 13:20:29 +00:00
|
|
|
modifier = "Mod4";
|
2022-01-18 13:12:43 +00:00
|
|
|
input = {
|
2022-01-18 13:14:12 +00:00
|
|
|
"*" = {
|
2022-01-18 13:12:43 +00:00
|
|
|
xkb_layout = "de,de";
|
|
|
|
xkb_variant = "neo_qwertz,neo";
|
2022-01-18 13:20:29 +00:00
|
|
|
xkb_options = "grp:ctrls_toggle";
|
2022-01-18 13:12:43 +00:00
|
|
|
};
|
|
|
|
};
|
2022-01-18 14:12:38 +00:00
|
|
|
output = {
|
2022-06-22 15:13:11 +00:00
|
|
|
"eDP-1" = {
|
|
|
|
bg = "${bg-1080p} fill";
|
|
|
|
};
|
2022-01-18 14:02:20 +00:00
|
|
|
"DP-1" = {
|
|
|
|
mode = "2560x1440@74.971Hz";
|
|
|
|
position = "0 0";
|
|
|
|
subpixel = "rgb";
|
|
|
|
adaptive_sync = "on";
|
2022-06-22 15:13:11 +00:00
|
|
|
bg = "${bg-1440p} fill";
|
2022-01-18 14:02:20 +00:00
|
|
|
};
|
|
|
|
"HDMI-A-1" = {
|
|
|
|
mode = "1920x1080@60Hz";
|
|
|
|
position = "2560 0";
|
|
|
|
subpixel = "rgb";
|
2022-06-22 15:13:11 +00:00
|
|
|
bg = "${bg-1080p} fill";
|
2022-01-18 14:02:20 +00:00
|
|
|
};
|
|
|
|
};
|
2022-06-12 15:39:15 +00:00
|
|
|
keybindings = let
|
2022-06-12 15:42:42 +00:00
|
|
|
inherit (config.wayland.windowManager.sway.config) modifier;
|
2022-06-12 15:39:15 +00:00
|
|
|
in
|
2022-01-19 08:28:39 +00:00
|
|
|
lib.mkOptionDefault {
|
2022-06-10 14:01:32 +00:00
|
|
|
"${modifier}+Return" = "exec ${pkgs.kitty}/bin/kitty";
|
2022-01-19 08:28:39 +00:00
|
|
|
"${modifier}+d" = "exec ${pkgs.wofi}/bin/wofi --show drun";
|
2022-01-19 09:12:58 +00:00
|
|
|
"Print" = "mode screenshot";
|
2022-03-11 17:44:19 +00:00
|
|
|
"XF86AudioRaiseVolume" = "exec ${pkgs.pulseaudio}/bin/pactl set-sink-volume @DEFAULT_SINK@ +5%";
|
|
|
|
"XF86AudioLowerVolume" = "exec ${pkgs.pulseaudio}/bin/pactl set-sink-volume @DEFAULT_SINK@ -5%";
|
|
|
|
"XF86AudioMute" = "exec ${pkgs.pulseaudio}/bin/pactl set-sink-mute @DEFAULT_SINK@ toggle";
|
2022-03-11 19:55:04 +00:00
|
|
|
"XF86AudioMicMute" = "exec ${pkgs.pulseaudio}/bin/pactl set-source-mute @DEFAULT_SOURCE@ toggle";
|
2022-03-11 17:44:19 +00:00
|
|
|
"XF86MonBrightnessDown" = "exec ${pkgs.brightnessctl}/bin/brightnessctl set 5%-";
|
|
|
|
"XF86MonBrightnessUp" = "exec ${pkgs.brightnessctl}/bin/brightnessctl set +5%";
|
|
|
|
"XF86AudioPlay" = "exec ${pkgs.mpc-cli}/bin/mpc toggle";
|
|
|
|
"XF86AudioNext" = "exec ${pkgs.mpc-cli}/bin/mpc next";
|
|
|
|
"XF86AudioPrev" = "exec ${pkgs.mpc-cli}/bin/mpc prev";
|
|
|
|
"XF86AudioStop" = "exec ${pkgs.mpc-cli}/bin/mpc stop";
|
2022-03-23 21:07:18 +00:00
|
|
|
"Mod1+Tab" = "exec ${switch_window}";
|
2022-01-19 08:28:39 +00:00
|
|
|
};
|
2022-01-18 15:57:45 +00:00
|
|
|
bars = [
|
|
|
|
{
|
|
|
|
command = "${pkgs.waybar}/bin/waybar";
|
|
|
|
}
|
|
|
|
];
|
2022-01-19 09:12:58 +00:00
|
|
|
modes = {
|
|
|
|
screenshot = {
|
2022-04-14 07:27:25 +00:00
|
|
|
Print = "exec ${screenshot_then_switch} copy area";
|
|
|
|
"Shift+Print" = "exec ${screenshot_then_switch} save area $HOME/Pictures/grim-$(date --iso=s).png";
|
|
|
|
a = "exec ${screenshot_then_switch} copy active";
|
|
|
|
"Shift+a" = "exec ${screenshot_then_switch} save active $HOME/Pictures/grim-$(date --iso=s).png";
|
|
|
|
s = "exec ${screenshot_then_switch} copy screen";
|
|
|
|
"Shift+s" = "exec ${screenshot_then_switch} save screen $HOME/Pictures/grim-$(date --iso=s).png";
|
|
|
|
o = "exec ${screenshot_then_switch} copy output";
|
|
|
|
"Shift+o" = "exec ${screenshot_then_switch} save output $HOME/Pictures/grim-$(date --iso=s).png";
|
|
|
|
w = "exec ${screenshot_then_switch} copy window";
|
|
|
|
"Shift+w" = "exec ${screenshot_then_switch} save window $HOME/Pictures/grim-$(date --iso=s).png";
|
2022-01-19 09:17:03 +00:00
|
|
|
Escape = ''mode "default"'';
|
|
|
|
Return = ''mode "default"'';
|
2022-01-19 09:12:58 +00:00
|
|
|
};
|
|
|
|
};
|
2022-01-18 14:21:38 +00:00
|
|
|
};
|
2022-01-18 15:55:32 +00:00
|
|
|
wrapperFeatures.gtk = true;
|
2022-07-06 06:59:56 +00:00
|
|
|
extraSessionCommands = ''
|
|
|
|
export SDL_VIDEODRIVER=wayland
|
|
|
|
export QT_QPA_PLATFORM=wayland
|
|
|
|
export QT_WAYLAND_DISABLE_WINDOWDECORATION="1"
|
2022-07-06 10:50:25 +00:00
|
|
|
export _JAVA_AWT_WM_NONREPARENTING=1
|
2022-07-06 07:09:27 +00:00
|
|
|
export MOZ_ENABLE_WAYLAND=1
|
|
|
|
export XDG_CURRENT_DESKTOP=sway
|
2022-07-10 13:49:32 +00:00
|
|
|
export GTK_USE_PORTAL=1
|
2022-07-06 06:59:56 +00:00
|
|
|
'';
|
|
|
|
extraConfig = ''
|
|
|
|
exec ${dbus-sway-environment}/bin/dbus-sway-environment
|
|
|
|
exec ${configure-gtk}/bin/configure-gtk
|
2022-07-06 07:09:27 +00:00
|
|
|
exec ${pkgs.systemd}/bin/systemctl --user import-environment
|
2022-07-06 06:59:56 +00:00
|
|
|
'';
|
2022-01-18 13:12:43 +00:00
|
|
|
};
|
2022-01-19 10:16:54 +00:00
|
|
|
|
2022-07-17 10:57:53 +00:00
|
|
|
home.file.".XCompose".source = ../../extra/.XCompose;
|
2022-01-18 14:02:20 +00:00
|
|
|
}
|