365 lines
14 KiB
Nix
365 lines
14 KiB
Nix
{ nixosConfig, config, lib, pkgs, stdenv, ... }:
|
||
|
||
let
|
||
solarized = import ../solarized.nix;
|
||
terminalEmulator =
|
||
if nixosConfig.jalr.terminalEmulator == "alacritty"
|
||
then
|
||
pkgs.writeShellScript "alacritty-sway-cwd" ''
|
||
this_alacritty_pid="$(${pkgs.sway}/bin/swaymsg -t get_tree | ${pkgs.jq}/bin/jq -e 'recurse(.nodes[]?) | select((.focused==true) and (.app_id=="Alacritty")).pid')"
|
||
|
||
if [ "$this_alacritty_pid" ]; then
|
||
child_pid="$(pgrep -P "$this_alacritty_pid")"
|
||
cwd="$(readlink /proc/$child_pid/cwd)"
|
||
fi
|
||
if [ -e "$cwd" ]; then
|
||
exec ${pkgs.alacritty}/bin/alacritty --working-directory "$cwd"
|
||
fi
|
||
|
||
exec ${pkgs.alacritty}/bin/alacritty
|
||
''
|
||
else nixosConfig.jalr.terminalEmulator;
|
||
cfg = config.wayland.windowManager.sway.config;
|
||
wallpaper = pkgs.fetchurl {
|
||
url = "https://raw.githubusercontent.com/swaywm/sway/3b2bc894a5ebbcbbd6707d45a25d171779c2e874/assets/Sway_Wallpaper_Blue_1920x1080.png";
|
||
sha256 = "1rkqd0h7w64plibn7k3krk5vdc3pnv3fc7m2xc2mxnwrbsgngwsz";
|
||
|
||
meta.license = lib.licenses.cc0;
|
||
};
|
||
move-to-output = pkgs.callPackage ./move-to-output { };
|
||
in
|
||
{
|
||
imports = lib.optionals nixosConfig.jalr.gui.enable [
|
||
./gammastep.nix
|
||
./waybar.nix
|
||
./wofi.nix
|
||
./wofi-bluetooth.nix
|
||
./yubikey-touch-detector.nix
|
||
];
|
||
} // (lib.mkIf nixosConfig.jalr.gui.enable {
|
||
home.packages = with pkgs; [
|
||
sway-contrib.grimshot # screenshots
|
||
wdisplays # graphical output manager
|
||
];
|
||
|
||
home.sessionVariables = {
|
||
ELM_ENGINE = "wayland_shm";
|
||
GDK_BACKEND = "wayland";
|
||
MOZ_DBUS_REMOTE = "1";
|
||
QT_QPA_PLATFORM = "wayland";
|
||
QT_WAYLAND_DISABLE_WINDOWDECORATION = "1";
|
||
_JAVA_AWT_WM_NONREPARENTING = "1";
|
||
};
|
||
|
||
#home.sessionVariables = {
|
||
# CLUTTER_BACKEND = "wayland";
|
||
# GDK_BACKEND = "wayland";
|
||
# GDK_DPI_SCALE = 1;
|
||
# MOZ_ENABLE_WAYLAND = 1;
|
||
# QT_QPA_PLATFORM = "wayland-egl";
|
||
# QT_WAYLAND_DISABLE_WINDOWDECORATION = 1;
|
||
# SDL_VIDEODRIVER = "wayland";
|
||
# WLR_NO_HARDWARE_CURSORS = 1;
|
||
# _JAVA_AWT_WM_NONREPARENTING = 1;
|
||
# _JAVA_OPTIONS = "-Dawt.useSystemAAFontSettings=on";
|
||
#};
|
||
|
||
programs.fish.loginShellInit = ''
|
||
if [ -z $WAYLAND_DISPLAY ] && [ (tty) = /dev/tty1 ]
|
||
export XDG_SESSION_TYPE="wayland" # otherwise set to tty
|
||
set -e __HM_SESS_VARS_SOURCED
|
||
set -e __NIXOS_SET_ENVIRONMENT_DONE
|
||
exec systemd-cat -t sway sway
|
||
end
|
||
'';
|
||
|
||
xdg.configFile."sway/light-theme".text = with solarized; ''
|
||
client.focused ${base01.hex} ${blue.hex} ${base3.hex} ${blue.hex} ${blue.hex}
|
||
client.focused_inactive ${base2.hex} ${base2.hex} ${base01.hex} ${base0.hex} ${base2.hex}
|
||
client.unfocused ${base2.hex} ${base3.hex} ${base01.hex} ${base2.hex} ${base2.hex}
|
||
client.urgent ${red.hex} ${red.hex} ${base3.hex} ${red.hex} ${red.hex}
|
||
'';
|
||
xdg.configFile."sway/dark-theme".text = with solarized; ''
|
||
client.focused ${base1.hex} ${blue.hex} ${base03.hex} ${blue.hex} ${blue.hex}
|
||
client.focused_inactive ${base02.hex} ${base02.hex} ${base1.hex} ${base03.hex} ${base02.hex}
|
||
client.unfocused ${base02.hex} ${base03.hex} ${base1.hex} ${base02.hex} ${base02.hex}
|
||
client.urgent ${red.hex} ${red.hex} ${base03.hex} ${red.hex} ${red.hex}
|
||
'';
|
||
|
||
wayland.windowManager.sway = {
|
||
enable = true;
|
||
|
||
config = {
|
||
modifier = "Mod4";
|
||
left = "n";
|
||
right = "t";
|
||
up = "g";
|
||
down = "r";
|
||
|
||
terminal = "${terminalEmulator}";
|
||
menu = "${pkgs.wofi}/bin/wofi --allow-images --show drun --color=$HOME/.config/wofi/color";
|
||
|
||
output."*".bg = "${wallpaper} fill";
|
||
|
||
# FIXME
|
||
#input = {
|
||
# #"type:keyboard" = {
|
||
# # xkb_layout = "neo";
|
||
# #};
|
||
#} // (lib.optionalAttrs (nixosConfig.networking.hostName == "mayushii") {
|
||
# "type:touchpad".events = "disabled";
|
||
# "2:10:TPPS/2_Elan_TrackPoint".pointer_accel = "-0.15";
|
||
#});
|
||
|
||
keybindings = {
|
||
"${cfg.modifier}+Return" = "exec ${cfg.terminal}";
|
||
"${cfg.modifier}+Backspace" = "exec ${cfg.terminal}";
|
||
|
||
|
||
"--to-code ${cfg.modifier}+Escape" = "exec ${cfg.menu}";
|
||
#"--to-code ${cfg.modifier}+udiaeresis" = "exec ${cfg.menu}";
|
||
|
||
"${cfg.modifier}+q" = "kill";
|
||
# "${cfg.modifier}+r" = "exec ${cfg.menu}";
|
||
# "${cfg.modifier}+Control+r" = "reload";
|
||
"${cfg.modifier}+Shift+q" = "exec ${pkgs.sway}/bin/swaynag -t warning -m 'You pressed the exit shortcut. Do you really want to exit sway? This will end your Wayland session.' -b 'Yes, exit sway' '${pkgs.sway}/bin/swaymsg exit'";
|
||
|
||
# Focus
|
||
"${cfg.modifier}+${cfg.left}" = "focus left";
|
||
"${cfg.modifier}+${cfg.down}" = "focus down";
|
||
"${cfg.modifier}+${cfg.up}" = "focus up";
|
||
"${cfg.modifier}+${cfg.right}" = "focus right";
|
||
|
||
"${cfg.modifier}+Left" = "focus left";
|
||
"${cfg.modifier}+Down" = "focus down";
|
||
"${cfg.modifier}+Up" = "focus up";
|
||
"${cfg.modifier}+Right" = "focus right";
|
||
|
||
# Moving
|
||
"${cfg.modifier}+Shift+${cfg.left}" = "move left";
|
||
"${cfg.modifier}+Shift+${cfg.down}" = "move down";
|
||
"${cfg.modifier}+Shift+${cfg.up}" = "move up";
|
||
"${cfg.modifier}+Shift+${cfg.right}" = "move right";
|
||
|
||
"${cfg.modifier}+Shift+Left" = "move left";
|
||
"${cfg.modifier}+Shift+Down" = "move down";
|
||
"${cfg.modifier}+Shift+Up" = "move up";
|
||
"${cfg.modifier}+Shift+Right" = "move right";
|
||
|
||
# Workspaces
|
||
"${cfg.modifier}+1" = "workspace number 1";
|
||
"${cfg.modifier}+2" = "workspace number 2";
|
||
"${cfg.modifier}+3" = "workspace number 3";
|
||
"${cfg.modifier}+4" = "workspace number 4";
|
||
"${cfg.modifier}+5" = "workspace number 5";
|
||
"${cfg.modifier}+6" = "workspace number 6";
|
||
"${cfg.modifier}+7" = "workspace number 7";
|
||
"${cfg.modifier}+8" = "workspace number 8";
|
||
"${cfg.modifier}+9" = "workspace number 9";
|
||
"${cfg.modifier}+0" = "workspace number 10";
|
||
|
||
"${cfg.modifier}+h" = "workspace prev_on_output";
|
||
"${cfg.modifier}+f" = "workspace next_on_output";
|
||
|
||
"${cfg.modifier}+Tab" = "workspace back_and_forth";
|
||
|
||
"${cfg.modifier}+Shift+1" = "move container to workspace number 1";
|
||
"${cfg.modifier}+Shift+2" = "move container to workspace number 2";
|
||
"${cfg.modifier}+Shift+3" = "move container to workspace number 3";
|
||
"${cfg.modifier}+Shift+4" = "move container to workspace number 4";
|
||
"${cfg.modifier}+Shift+5" = "move container to workspace number 5";
|
||
"${cfg.modifier}+Shift+6" = "move container to workspace number 6";
|
||
"${cfg.modifier}+Shift+7" = "move container to workspace number 7";
|
||
"${cfg.modifier}+Shift+8" = "move container to workspace number 8";
|
||
"${cfg.modifier}+Shift+9" = "move container to workspace number 9";
|
||
"${cfg.modifier}+Shift+0" = "move container to workspace number 10";
|
||
|
||
# Moving workspaces between outputs
|
||
"${cfg.modifier}+Control+${cfg.left}" = "move workspace to output left";
|
||
"${cfg.modifier}+Control+${cfg.down}" = "move workspace to output down";
|
||
"${cfg.modifier}+Control+${cfg.up}" = "move workspace to output up";
|
||
"${cfg.modifier}+Control+${cfg.right}" = "move workspace to output right";
|
||
|
||
"${cfg.modifier}+Shift+h" = "exec ${move-to-output}/bin/move-to-output previous";
|
||
"${cfg.modifier}+Shift+f" = "exec ${move-to-output}/bin/move-to-output next";
|
||
|
||
"${cfg.modifier}+Control+Left" = "move workspace to output left";
|
||
"${cfg.modifier}+Control+Down" = "move workspace to output down";
|
||
"${cfg.modifier}+Control+Up" = "move workspace to output up";
|
||
"${cfg.modifier}+Control+Right" = "move workspace to output right";
|
||
|
||
# Splits
|
||
"${cfg.modifier}+e" = "splith";
|
||
"${cfg.modifier}+a" = "splitv";
|
||
|
||
# Layouts
|
||
"${cfg.modifier}+j" = "layout stacking";
|
||
"${cfg.modifier}+period" = "layout tabbed";
|
||
"${cfg.modifier}+comma" = "layout toggle split";
|
||
"${cfg.modifier}+m" = "fullscreen toggle";
|
||
|
||
#"${cfg.modifier}+a" = "focus parent";
|
||
|
||
"${cfg.modifier}+Shift+space" = "floating toggle";
|
||
"${cfg.modifier}+space" = "focus mode_toggle";
|
||
|
||
## Scratchpad
|
||
"${cfg.modifier}+Shift+b" = "move scratchpad";
|
||
"${cfg.modifier}+b" = "scratchpad show";
|
||
|
||
## Resize mode
|
||
"${cfg.modifier}+s" = "mode resize";
|
||
|
||
## Multimedia Keys
|
||
#"XF86AudioMute" = "exec ${pkgs.pulseaudio}/bin/pactl set-sink-mute @DEFAULT_SINK@ toggle";
|
||
#"XF86AudioMicMute" = "exec ${pkgs.pulseaudio}/bin/pactl set-source-mute @DEFAULT_SOURCE@ toggle";
|
||
#"--locked XF86MonBrightnessDown" = "exec ${pkgs.brightnessctl}/bin/brightnessctl set 5%-";
|
||
#"--locked XF86MonBrightnessUp" = "exec ${pkgs.brightnessctl}/bin/brightnessctl set +5%";
|
||
#"XF86AudioRaiseVolume" = "exec ${pkgs.pulseaudio}/bin/pactl set-sink-volume @DEFAULT_SINK@ +5%";
|
||
#"XF86AudioLowerVolume" = "exec ${pkgs.pulseaudio}/bin/pactl set-sink-volume @DEFAULT_SINK@ -5%";
|
||
|
||
#"XF86AudioPrev" = "exec ${pkgs.mpc_cli}/bin/mpc -q next";
|
||
#"XF86AudioNext" = "exec ${pkgs.mpc_cli}/bin/mpc -q prev";
|
||
#"XF86AudioPlay" = "exec ${pkgs.mpc_cli}/bin/mpc -q toggle";
|
||
|
||
## Mumble PTT
|
||
#"--no-repeat Shift_R" = "exec ${pkgs.dbus}/bin/dbus-send --session --type=method_call --dest=net.sourceforge.mumble.mumble / net.sourceforge.mumble.Mumble.startTalking";
|
||
#"--no-repeat --release Shift_R" = "exec ${pkgs.dbus}/bin/dbus-send --session --type=method_call --dest=net.sourceforge.mumble.mumble / net.sourceforge.mumble.Mumble.stopTalking";
|
||
## reset
|
||
#"Shift_R+Shift" = "exec ${pkgs.dbus}/bin/dbus-send --session --type=method_call --dest=net.sourceforge.mumble.mumble / net.sourceforge.mumble.Mumble.stopTalking";
|
||
|
||
|
||
"XF86AudioMute" = "exec pactl set-source-mute alsa_input.usb-BEHRINGER_UMC202HD_192k-00.HiFi__umc202hd_mono_in_U192k_0_1__source toggle";
|
||
|
||
"${cfg.modifier}+l" = "exec ${pkgs.swaylock}/bin/swaylock -f -i ${wallpaper}";
|
||
};
|
||
|
||
bars = [ ]; # managed as systemd user unit
|
||
|
||
assigns = {
|
||
"5" = [
|
||
{ app_id = "firefox"; }
|
||
{ app_id = "anki"; }
|
||
];
|
||
"3" = [
|
||
{ class = "Claws-mail"; }
|
||
];
|
||
"4" = [
|
||
{ app_id = "net.sourceforge.mumble."; }
|
||
];
|
||
"2" = [
|
||
{ app_id = "audacious"; }
|
||
{ app_id = "pavucontrol"; }
|
||
];
|
||
"7" = [
|
||
{ app_id = "net.sourceforge.gscan2pdf"; }
|
||
{ app_id = "libreoffice-startcenter"; }
|
||
];
|
||
"8" = [
|
||
{ app_id = "darktable"; }
|
||
{ app_id = "org.inkscape.Inkscape"; }
|
||
{ class = "Blender"; }
|
||
{ class = "Gimp"; }
|
||
{ class = "krita"; }
|
||
];
|
||
};
|
||
|
||
window.commands = [
|
||
{
|
||
criteria = { app_id = "firefox"; title = "Firefox — Sharing Indicator"; };
|
||
command = "kill";
|
||
}
|
||
];
|
||
|
||
window.border = 2;
|
||
gaps = {
|
||
inner = 6;
|
||
smartGaps = false;
|
||
};
|
||
|
||
floating = {
|
||
titlebar = true;
|
||
border = 1;
|
||
};
|
||
|
||
fonts = {
|
||
names = [ "monospace" ];
|
||
style = "Regular";
|
||
size = 10.0;
|
||
};
|
||
};
|
||
|
||
extraConfig = ''
|
||
include ~/.config/sway/theme
|
||
# Cursor
|
||
seat seat0 xcursor_theme Adwaita
|
||
'' + (
|
||
let
|
||
environmentVariables = lib.concatStringsSep " " [
|
||
"DBUS_SESSION_BUS_ADDRESS"
|
||
"DISPLAY"
|
||
"SWAYSOCK"
|
||
"WAYLAND_DISPLAY"
|
||
];
|
||
in
|
||
''
|
||
# From https://github.com/swaywm/sway/wiki#gtk-applications-take-20-seconds-to-start
|
||
exec systemctl --user import-environment ${environmentVariables} && \
|
||
hash dbus-update-activation-environment 2>/dev/null && \
|
||
dbus-update-activation-environment --systemd ${environmentVariables} && \
|
||
systemctl --user start sway-session.target
|
||
''
|
||
);
|
||
};
|
||
|
||
systemd.user.targets.sway-session = {
|
||
Unit = {
|
||
Description = "sway compositor session";
|
||
Documentation = [ "man:systemd.special(7)" ];
|
||
BindsTo = [ "graphical-session.target" ];
|
||
Wants = [ "graphical-session-pre.target" ];
|
||
After = [ "graphical-session-pre.target" ];
|
||
};
|
||
};
|
||
|
||
systemd.user.services.swayidle = {
|
||
Unit.PartOf = [ "sway-session.target" ];
|
||
Install.WantedBy = [ "sway-session.target" ];
|
||
|
||
Service = {
|
||
# swayidle requires sh and swaymsg to be in path
|
||
Environment = "PATH=${pkgs.bash}/bin:${config.wayland.windowManager.sway.package}/bin";
|
||
ExecStart = ''
|
||
${pkgs.swayidle}/bin/swayidle -w \
|
||
timeout 300 "${pkgs.swaylock}/bin/swaylock -f -i ${wallpaper}" \
|
||
timeout 300 '${pkgs.sway}/bin/swaymsg "output * dpms off"' \
|
||
resume '${pkgs.sway}/bin/swaymsg "output * dpms on"' \
|
||
before-sleep "${pkgs.swaylock}/bin/swaylock -f -i ${wallpaper}"
|
||
'';
|
||
Restart = "on-failure";
|
||
};
|
||
};
|
||
|
||
xdg.configFile."swaynag/config".text =
|
||
let
|
||
# adding it to the header doesn’t work since the defaults overwrite it
|
||
commonConfig = /* ini */ ''
|
||
background=${lib.substring 1 6 solarized.base3.hex}
|
||
border-bottom=${lib.substring 1 6 solarized.base2.hex}
|
||
border=${lib.substring 1 6 solarized.base2.hex}
|
||
button-background=${lib.substring 1 6 solarized.base3.hex}
|
||
button-text=${lib.substring 1 6 solarized.base00.hex}
|
||
'';
|
||
in
|
||
/* ini */ ''
|
||
font=Monospace 12
|
||
|
||
[warning]
|
||
text=${lib.substring 1 6 solarized.yellow.hex}
|
||
${commonConfig}
|
||
|
||
[error]
|
||
text=${lib.substring 1 6 solarized.red.hex}
|
||
${commonConfig}
|
||
'';
|
||
})
|