dotfiles-nix/modules/sway/default.nix

225 lines
7.1 KiB
Nix

{ config, pkgs, lib, ... }:
{
home.packages = with pkgs; [
feh dmenu blueman
wl-clipboard swaybg slurp copyq
gnome-calculator grim swappy xarchiver
(flameshot.override { enableWlrSupport = true; })
];
services.blueman-applet.enable = true;
services.gnome-keyring.enable = true;
programs.wofi.enable = true;
programs.waybar.enable = true;
services.dunst = {
enable = true;
settings = {
global = {
width = 300;
height = "(0, 300)";
origin = "top-right";
offset = "(10, 50)";
notification_limit = 20;
tranasparency = 25;
separator_geight = 3;
padding = 8;
horizontal_padding = 8;
frame_width = 3;
frame_color = "#4c7899";
font = "Monospace 8";
alignment = "left";
min_icon_size = 32;
max_icon_size = 64;
corner_radius = 15;
corners = "all";
};
urgency_low = {
background = "#222222";
foreground = "#888888";
timeout = 10;
};
urgency_normal = {
background = "#285577";
foreground = "#ffffff";
timeout = 10;
override_pause_level = 30;
};
urgency_critical = {
background = "#891818";
foreground = "#ffffff";
frame_color = "#ab2828";
timeout = 0;
override_pause_level = 60;
};
ignore_flameshot_warning = {
body = "grim's screenshot component is implemented based on wlroots, it may not be used in GNOME or similar desktop environments";
format = "";
};
};
};
home.pointerCursor = {
enable = true;
name = "Adwaita";
package = pkgs.adwaita-icon-theme;
size = 16;
sway.enable = true;
x11.enable = true;
gtk.enable = true;
};
wayland.windowManager.sway = {
enable = true;
wrapperFeatures.gtk = true;
extraOptions = [
"--unsupported-gpu"
];
extraSessionCommands = ''
# Hardware cursors not yet working on wlroots
export WLR_NO_HARDWARE_CURSORS=1
# Set wlroots renderer to Vulkan to avoid flickering
# export WLR_RENDERER=vulkan
# General wayland environment variables
export XDG_SESSION_TYPE=wayland
export QT_QPA_PLATFORM=wayland
export QT_WAYLAND_DISABLE_WINDOWDECORATION=1
# Firefox wayland environment variable
export MOZ_ENABLE_WAYLAND=1
export MOZ_USE_XINPUT2=1
# OpenGL Variables
export GBM_BACKEND=nvidia-drm
export __GL_GSYNC_ALLOWED=0
export __GL_VRR_ALLOWED=0
export __GLX_VENDOR_LIBRARY_NAME=nvidia
# Xwayland compatibility
export XWAYLAND_NO_GLAMOR=1
'';
config = {
defaultWorkspace = "workspace number 1";
menu = "wofi --show run";
terminal = "kitty";
modifier = "Mod4";
focus.followMouse = "no";
bars = [ { command = "${pkgs.waybar}/bin/waybar"; } ];
fonts = {
names = [ "Fira Code" ];
size = 11.0;
};
bindkeysToCode = true;
keybindings = let
modifier = config.wayland.windowManager.sway.config.modifier;
homeDir = config.home.homeDirectory;
in lib.mkOptionDefault {
"${modifier}+z" = "exec ${homeDir}/.config/sway/idle.sh";
"${modifier}+Shift+s" = "sticky toggle";
"${modifier}+Shift+b" = "border toggle";
"${modifier}+g" = "exec ${homeDir}/.config/sway/random-bg.py onetime";
"${modifier}+n" = "exec pcmanfm";
"Print" = "exec flameshot gui --raw | wl-copy";
"Shift+Print" = "exec grim - | wl-copy";
"${modifier}+Print" = "exec flameshot gui --raw | feh --auto-zoom --scale-down -";
"${modifier}+c" = "exec copyq toggle";
"${modifier}+o" = "exec gnome-calculator";
"${modifier}+i" = "exec firefox";
"XF86AudioMute" = "exec pactl set-sink-mute @DEFAULT_SINK@ toggle";
"XF86AudioLowerVolume" = "exec pactl set-sink-volume @DEFAULT_SINK@ -5%";
"XF86AudioRaiseVolume" = "exec pactl set-sink-volume @DEFAULT_SINK@ +5%";
"XF86AudioMicMute" = "exec pactl set-source-mute @DEFAULT_SOURCE@ toggle";
};
input = {
"type:keyboard" = {
xkb_layout = "us,ru";
xkb_options = "grp:alt_caps_toggle";
xkb_numlock = "enabled";
};
};
startup = [
{ command = "${config.home.homeDirectory}/.config/sway/startup.sh"; }
{ command = "${config.home.homeDirectory}/.config/sway/idle.sh"; }
];
window.commands = let
mk = command: criteria: {
command = command;
criteria = criteria;
};
popup = mk "floating enable; border pixel 1; sticky enable; shadows enable";
float = mk "floating enable; border pixel 1; shadows enable";
no_title = mk "border pixel 1";
video = mk "inhibit_idle fullscreen; border none; max_render_time off";
important = mk "inhibit_idle open; floating enable; border pixel 1";
app_id = a: { app_id = a; };
title = a: { title = a; };
class = a: { class = a; };
window_type = a: { window_type = a; };
pcmanfm_title = a: { app_id = "pcmanfm"; title = a; };
in [
(no_title (app_id "kitty"))
(popup (app_id "dunst"))
(popup (app_id "com.github.hluk.copyq"))
(popup (app_id "pavucontrol"))
(popup (app_id "qtalarm"))
(popup (app_id "blueman-manager"))
(popup (class "feh"))
(popup (title "Picture-in-Picture"))
(popup (title "Picture in picture"))
(float {window_role = "pop-up,task_dialog,About";})
(float (window_type "dialog"))
(float (window_type "utility"))
(float (window_type "toolbar"))
(float (window_type "splash"))
(float (window_type "menu"))
(float (window_type "dropdown_menu"))
(float (window_type "popup_menu"))
(float (window_type "tooltip"))
(float (window_type "notification"))
(float (class "bRAC"))
(float (app_id "org.gnome.clocks"))
(float (app_id "org.gnome.Calculator"))
(float (app_id "galculator"))
(video (app_id "mpv"))
(video (app_id "vlc"))
(video (app_id "firefox"))
(video (app_id "org.telegram.desktop"))
(video {instance = "chromium";})
(video (class "firefox"))
(video (class "Nightly"))
(important { app_id = "xarchiver"; })
(important (pcmanfm_title "Confirm to replace files"))
(important (pcmanfm_title "(?:Open|Save) (?:File|Folder|As)"))
(important (pcmanfm_title "^(File|Folder)\s*Already Exists\s*\s*"))
(important (pcmanfm_title "Move files"))
(important (pcmanfm_title "Copy Files"))
(important (pcmanfm_title "Delete Files"))
(important (pcmanfm_title "Removable medium is inserted"))
];
};
};
xdg.configFile."sway/idle.sh".source = ./idle.sh;
xdg.configFile."sway/startup.sh".source = ./startup.sh;
xdg.configFile."sway/wallpaper.jpg".source = ../wallpaper.jpg;
xdg.configFile."waybar" = { source = ./waybar; recursive = true; };
xdg.mimeApps.defaultApplications = {
"inode/directory" = "pcmanfm.desktop";
};
}