All Sway config is now a module

This commit is contained in:
Yorick Barbanneau 2023-12-26 02:48:49 +01:00
parent 559a477e05
commit 8c62cc41d1
22 changed files with 685 additions and 662 deletions

View file

@ -1,6 +1,7 @@
{ lib, config, pkgs, ... }:
{
imports = [
./desktop/sway
./gaming/lutris
./video/kdenlive
./web/qutebrowser/default.nix

View file

@ -0,0 +1,105 @@
{ lib, config, pkgs, ... }:
with lib;
let
cfg = config.modules.desktop.sway;
in
{
options.modules.desktop.sway = {
enable = mkEnableOption "enable Sway Windows Manager";
kanshi = mkOption {
type = types.bool;
default = false;
description = "configure laptop mode";
};
};
imports = [
./includes/fuzzel.nix
./includes/kanshi.nix
./includes/mako.nix
./includes/sway.nix
./includes/swayidle.nix
./includes/swaylock.nix
./includes/waybar.nix
];
config = mkIf cfg.enable {
programs.fuzzel.enable = true;
home.packages = with pkgs; [
dejavu_fonts
emojione
font-awesome
grim
lato
liberation_ttf
libertine
libnotify
(nerdfonts.override {
fonts = [
"FiraCode"
];
})
noto-fonts-emoji
noto-fonts-cjk
slurp
wl-clipboard
xdg-utils
];
programs.zsh.loginExtra = ''
if [ "$(tty)" = "/dev/tty1" ]; then
exec sway &> /dev/null
fi
'';
gtk = {
enable = true;
theme = {
name = "Arc-Dark";
package = pkgs.arc-theme;
};
iconTheme = {
name = "Papirus Dark";
package = pkgs.papirus-icon-theme;
};
font = {
name = "Deja Vu Sans";
package = "${pkgs.dejavu_fonts}";
size = 10;
};
};
home.pointerCursor = {
name = "Adwaita";
package = pkgs.gnome.adwaita-icon-theme;
size = 24;
x11 = {
enable = true;
defaultCursor = "Adwaita";
};
};
qt = {
enable = true;
platformTheme = "gnome";
style.name = "adwaita-dark";
};
xdg = {
enable = true;
mimeApps.enable = true;
userDirs = {
enable = true;
createDirectories = true;
documents = "documents";
download = "downloads";
music = "medias/musics";
pictures = "medias/images";
videos = "medias/videos";
templates = "tmp";
desktop = "documents";
publicShare = "tmp/public";
};
};
};
}

View file

@ -0,0 +1,29 @@
{ config, pkgs, lib, ... }:
with lib;
{
config = mkIf config.modules.desktop.sway.enable {
programs.fuzzel = {
settings = {
main = {
font = "Fira Code Nerd Font Mono:size=9";
icon-theme = "Papirus-Dark";
width = 60;
show-actions = "yes";
launch-prefix = "swaymsg exec --";
};
border = {
radius = 0;
width = 1;
};
colors = {
border = "f268b3ff";
background = "121212ff";
text = "ccccccff";
selection = "323232ff";
selection-text = "ccccccff";
match = "f268b3ff";
};
};
};
};
}

View file

@ -0,0 +1,50 @@
{ config, lib, ... }:
with lib;
{
config = mkIf config.modules.desktop.sway.enable {
services.kanshi = {
enable = config.modules.desktop.sway.kanshi ;
profiles = {
home = {
outputs = [
{
criteria = "Iiyama North America PL2792UH 1166310803122";
mode = "3840x2160";
position = "1080,0";
scale = 2.0;
}
{
criteria = "Iiyama North America PL2792UH 1176923201598";
mode = "3840x2160";
position = "0,0";
transform = "90";
scale = 2.0;
}
{
criteria = "eDP-1";
status = "disable";
}
];
};
work = {
outputs = [
{
criteria = "Iiyama North America PL2480H 11183M2807013";
mode = "1920x1080";
position = "0,0";
}
{
criteria = "Iiyama North America PL2480H 11183M2807016";
mode = "1920x1080";
position = "1920,0";
}
{
criteria = "eDP-1";
status = "disable";
}
];
};
};
};
};
}

View file

@ -0,0 +1,39 @@
{ config, pkgs, lib, ... }:
with lib;
{
config = mkIf config.modules.desktop.sway.enable {
systemd.user.services.mako = {
Service = {
ExecStart = "${pkgs.mako}/bin/mako";
};
Install = {
After = [ "sway-session.target" ];
WantedBy = [ "sway-session.target" ];
};
};
services.mako = {
enable = true;
font = "Fira Code 10";
backgroundColor = "#353535FF";
borderColor = "#1CD180";
progressColor = "over #5566AAFF";
textColor = "#FDFDFD";
width = 300;
height = 100;
borderRadius = 0;
borderSize = 2;
icons = true;
maxIconSize = 64;
layer = "overlay";
anchor = "top-right";
extraConfig = ''
[urgency="high"]
border-color=#F268b3
[app-name="cmus"]
border-color=#00000000
default-timeout=10000
'';
};
};
}

View file

@ -0,0 +1,196 @@
{ config, pkgs, lib, ... }:
with lib;
{
config = mkIf config.modules.desktop.sway.enable {
wayland.windowManager.sway = {
enable = true;
wrapperFeatures.gtk = true;
systemd.enable = true;
config = {
modifier = "Mod4";
terminal = "${pkgs.foot}/bin/foot";
left = "h";
down = "j";
up = "k";
right = "l";
bars= [];
input = {
"1003:8258:MNT_Reform_Keyboard" = {
xkb_layout = "us";
xkb_variant = "altgr-intl";
};
};
seat = {
"*".hide_cursor = "when-typing enable";
};
keybindings = let
mod = config.wayland.windowManager.sway.config.modifier;
inherit (config.wayland.windowManager.sway.config)
left down up right terminal;
in
{
"${mod}+1" = "workspace $ws1";
"${mod}+Shift+1" = "move container to workspace $ws1";
"${mod}+2" = "workspace $ws2";
"${mod}+Shift+2" = "move container to workspace $ws2";
"${mod}+3" = "workspace $ws3";
"${mod}+Shift+3" = "move container to workspace $ws3";
"${mod}+4" = "workspace $ws4";
"${mod}+Shift+4" = "move container to workspace $ws4";
"${mod}+5" = "workspace $ws5";
"${mod}+Shift+5" = "move container to workspace $ws5";
"${mod}+6" = "workspace $ws6";
"${mod}+Shift+6" = "move container to workspace $ws6";
"${mod}+7" = "workspace $ws7";
"${mod}+Shift+7" = "move container to workspace $ws7";
"${mod}+8" = "workspace $ws8";
"${mod}+Shift+8" = "move container to workspace $ws8";
"${mod}+9" = "workspace $ws9";
"${mod}+Shift+9" = "move container to workspace $ws9";
"${mod}+0" = "workspace $ws0";
"${mod}+Shift+0" = "move container to workspace $ws0";
"${mod}+Return" = "exec ${terminal}";
"${mod}+Shift+q" = "kill";
"${mod}+d" = "exec ${pkgs.fuzzel}/bin/fuzzel";
"${mod}+Shift+c" = "reload";
"${mod}+Alt+l" = "exec ${pkgs.swaylock}/bin/swaylock";
"${mod}+${left} focus" = "left";
"${mod}+${down} focus" = "down";
"${mod}+${up} focus" = "up";
"${mod}+${right} focus" = "right";
"${mod}+Left" = "focus left";
"${mod}+Down" = "focus down";
"${mod}+Up" = "focus up";
"${mod}+Right" = "focus right";
"${mod}+Shift+${left} move" = "left";
"${mod}+Shift+${down} move" = "down";
"${mod}+Shift+${up} move" = "up";
"${mod}+Shift+${right} move" = "right";
"${mod}+Shift+Left" = "move left";
"${mod}+Shift+Down" = "move down";
"${mod}+Shift+Up" = "move up";
"${mod}+Shift+Right" = "move right";
"${mod}+b" = "splith";
"${mod}+v" = "splitv";
"${mod}+s" = "layout stacking";
"${mod}+w" = "layout tabbed";
"${mod}+e" = "layout toggle split";
"${mod}+f" = "fullscreen";
"${mod}+Shift+space" = "floating toggle";
"${mod}+space" = "focus mode_toggle";
"${mod}+a" = "focus parent";
"${mod}+Shift+p" = "move scratchpad";
"${mod}+p" = "scratchpad show";
"${mod}+F1" = "exec ${pkgs.brightnessctl}/bin/brightnessctl s 1%-";
"${mod}+F2" = "exec ${pkgs.brightnessctl}/bin/brightnessctl s +1%";
"${mod}+F3" = "exec ${pkgs.wireplumber}/bin/wpctl set-volume @DEFAULT_SINK@ 5%-";
"${mod}+F4" = "exec ${pkgs.wireplumber}/bin/wpctl set-volume @DEFAULT_SINK@ 5%+";
"${mod}+F5" = "exec ${pkgs.wireplumber}/bin/wpctl set-mute @DEFAULT_SINK@ toggle";
"${mod}+m" = "exec ${pkgs.wireplumber}/bin/wpctl set-mute @DEFAULT_SOURCE@ toggle";
"${mod}+r" = "mode resize";
"${mod}+n" = "exec makoctl dismiss";
"${mod}+shift+n" = "exec makoctl dismiss -a";
"${mod}+alt+n" = "mode notification";
};
modes =
let
inherit (config.wayland.windowManager.sway.config)
left down up right;
in {
"resize" = {
"${left}" = "resize shrink width 10 px or 10 ppt";
"${down}" = "resize grow height 10 px or 10 ppt";
"${up}" = "resize shrink height 10 px or 10 ppt";
"${right}" = "resize grow width 10 px or 10 ppt";
"Return" = "mode default";
"Escape" = "mode default";
};
"notification" = {
"r" = "exec ${pkgs.mako}/bin/makoctl restore";
"Escape" = "mode default";
};
};
colors = {
focused = {
border = "#f268b3";
background = "#f268b3";
text = "#000000";
indicator = "#1cd180";
childBorder = "#f268b3";
};
focusedInactive = {
border = "#323232";
background = "#323232";
text = "#f268b3";
indicator = "#1cd180";
childBorder = "#323232";
};
unfocused = {
border = "#323232";
background = "#323232";
text = "#cccccc";
indicator = "#1cd180";
childBorder = "#323232";
};
urgent = {
border = "#2f343a";
background = "#900000";
text = "#cccccc";
indicator = "#900000";
childBorder = "#900000" ;
};
#focused_tab_title = {
# boder = "#2f343a";
# background = "#2f343a";
# text = "#ffffff";
#};
};
window = {
border = 1;
titlebar = false;
commands = [
{
command = "inhibit_idle fullscreen";
criteria = {
title = "^.*";
};
}
{
command = "inhibit_idle fullscreen";
criteria = {
app_id = "^.*";
};
}
];
};
gaps = {
smartGaps = true;
smartBorders = "on";
inner = 2;
};
assigns = {
"$ws3" = [{app_id = "firefox";} {app_id = "org.qutebrowser.qutebrowser";}];
"$ws4" = [{app_id = "WebCord";}];
"$ws7" = [{app_id = "org.inkscape.Inkscape";} {app_id = "org.kde.kdenlive";}];
};
};
extraConfigEarly = ''
set $ws1 1:
set $ws2 2: 󰇮
set $ws3 3: 󰈹
set $ws4 4: 󰍦
set $ws5 5:
set $ws6 6: 󰈙
set $ws7 7: 󰤚
set $ws8 8:
set $ws9 9:
set $ws0 10:
default_orientation auto
workspace_layout default
font pango:Fira Code Nerd Font Mono 10
default_border pixel 1
title_align right
'';
};
};
}

View file

@ -0,0 +1,30 @@
{ config, lib, pkgs, ... }:
with lib;
{
config = mkIf config.modules.desktop.sway.enable {
services.swayidle = {
enable = true;
timeouts = [
{
timeout = 300;
command = "${pkgs.swaylock}/bin/swaylock -f";
}
{
timeout = 600;
command = ''${pkgs.sway}/bin/swaymsg "output * power off"'';
resumeCommand = ''${pkgs.sway}/bin/swaymsg "output * power on"'';
}
];
events = [
{
event = "before-sleep";
command = "${pkgs.swaylock}/bin/swaylock -f";
}
{
event = "lock";
command = "${pkgs.swaylock}/bin/swaylock -f";
}
];
};
};
}

View file

@ -0,0 +1,33 @@
{ config, lib, ... }:
with lib;
{
config = mkIf config.modules.desktop.sway.enable {
programs.swaylock = {
enable = true;
settings = {
image = "~/medias/images/wallpapers/lockscreen.png";
scaling = "center";
color = "000000";
indicator-radius = 70;
indicator-y-position = 150;
font = "Fira Code Nerd Font Mono";
font-size = "14";
inside-color = "00000000";
ring-color = "323232";
ring-ver-color = "1cd180";
inside-ver-color = "1cd180cc";
ring-wrong-color = "f268b3";
inside-wrong-color = "f268b3cc";
key-hl-color = "1cd180";
caps-lock-key-hl-color = "1cd180";
caps-lock-bs-hl-color = "f268b3";
bs-hl-color = "f268b3ff";
separator-color = "00000000";
ignore-empty-password = true;
show-failed-attempts = true;
daemonize = true;
line-uses-inside = true;
};
};
};
}

View file

@ -0,0 +1,255 @@
{config, lib, ...}:
with lib;
{
config = mkIf config.modules.desktop.sway.enable {
programs.waybar = {
enable = true;
systemd = {
enable = true;
target = "sway-session.target";
};
settings = {
mainbar = {
layer = "top";
spacing = 6;
disable-toolptips = true;
modules-center = [];
modules-left = [
"sway/workspaces"
"sway/mode"
];
modules-right = [
"network"
"custom/sep"
"backlight"
"battery"
"custom/sep"
"memory"
"cpu"
"custom/sep"
"pulseaudio"
"custom/sep"
"clock"
"custom/sep"
"tray"
];
"clock" = {
"format-alt" = "{:%Y-%m-%d}";
"timezone" = "Europe/Paris";
"tooltip" = false;
};
"cpu" = {
"format" = "{usage}% {icon}";
"format-icons" = [ "" ];
"states" = {
"critical" = 90;
"warning" = 70;
};
"tooltip" = false;
};
"custom/sep" = {
"format" = "|";
"tooltip" = false;
};
"idle_inhibitor" = {
"format" = "{icon}";
"format-icons" = {
"activated" = "";
"deactivated" = "";
};
};
"memory" = {
"format" = "{used:0.1f}G/{total:0.1f}G ";
"interval" = 30;
"states" = {
"critical" = 90;
"warning" = 70;
};
};
"network" = {
"format-alt" = "{ifname}: {ipaddr}/{cidr}";
"format-disconnected" = "Disconnected ";
"format-ethernet" = "{ifname}: {ipaddr}/{cidr} 󰈀 ";
"format-linked" = "{ifname} (No IP) 󰈀 ";
"format-wifi" = "{essid} ({signalStrength}%) ";
"tooltip" = false;
};
"pulseaudio" = {
"format" = "{format_source} {volume}% {icon} ";
"format-bluetooth" = "{volume}% {icon}";
"format-icons" = {
"car" = "";
"default" = "";
"handsfree" = "󰋎";
"headphones" = "󰋋";
"headset" = "󰋎";
"phone" = "";
"portable" = "";
};
"format-muted" = "{format_source} 󰝟 ";
"format-source" = "{volume}% ";
"format-source-muted" = " ";
"tooltip" = false;
};
"sway/mode" = {
"format" = "<span style=\"italic\">{}</span>";
};
"sway/workspace" = {
"disable-scroll" = true;
};
"temperature" = {
"critical-threshold" = 80;
"format" = "{temperatureC}°C ";
"thermal-zone" = "6";
};
"backlight" = {
"format" = "{percent}% {icon}";
"format-icons" = [
"󰌶"
"󱩏"
"󱩐"
"󱩐"
"󱩑"
"󱩒"
"󱩓"
"󱩔"
"󱩕"
"󱩖"
"󰛨"
];
};
"battery" = {
"tooltip" = false;
"states" = {
"full" = 100;
"warning" = 30;
"critical" = 15;
};
"format" = "{capacity}% {icon}";
"format-charging" = "{capacity}% 󰓦";
"format-plugged" = "{capacity}% ";
"format-alt" = "{time} {icon}";
"format-icons" = [
" "
" "
" "
" "
" "
];
};
};
};
style = ''
@define-color color-base-bg #323232;
@define-color color-base-fg #ddd;
@define-color color-hover #f268b3;
@define-color color-selected #1cd180;
@define-color color-ok #1cd180;
@define-color color-warning #f2b768;
@define-color color-critical #f268b3;
* {
border: none;
border-radius: 0;
min-height:0;
}
window#waybar {
background: @color-base-bg ;
color: @color-base-fg;
font-family: "Fira Code Nerd Font";
font-size: 12px;
}
button,
button:disabled,label:disabled{
color:inherit;
}
button:hover{
background:none;
box-shadow:inherit;
box-shadow:inherit;
text-shadow:inherit;
text-shadow:inherit;
border-top:none;
}
#workspaces {
color:#fff;
}
#workspaces button {
margin:0 3px;
padding:4px 4px;
color:#9c9c9c;
border-bottom: 1px solid transparent;
}
#workspaces button:hover {
box-shadow:inherit;
text-shadow:inherit;
color: @color-hover;
border-bottom: 1px solid @color-hover;
}
#workspaces button.visible:not(.focused) {
color: @color-selected;
border-color: @color-selected;
}
#clock,
#cpu,
#memory,
#backlight,
#network,
#tray,
#mode,
#battery,
#idle_inhibitor {
padding: 2px 4px;
margin: 0;
background-color: transparent;
}
#mode{
background:@color-warning;
font-weight:bold;
}
#pulseaudio {}
#pulseaudio.muted {
color:@color-critical;
}
#battery.discharging {
color: @color-base-fg;
border-bottom: none;
}
#battery.charging, #battery.plugged {
border-bottom: 1px solid @color-ok;
color: @color-selected;
}
#battery.critical:not(.charging),
#cpu.critical,
#memory.critical{
border-color: @color-critical;
color: @color-critical;
}
#battery.warning:not(.charging),
#cpu.warning,
#memory.warning{
border-color: @color-warning;
color: @color-warning;
}
#tray {
font-family: "DejaVu sans";
font-size: 12px;
}
'';
};
};
}

View file

@ -0,0 +1,7 @@
{
programs.zsh.loginExtra = ''
if [ "$(tty)" = "/dev/tty1" ]; then
exec sway &> /dev/null
fi
'';
}