Initial sway config, some tweaks to base system

This commit is contained in:
Erwin Boskma 2021-10-18 21:45:28 +02:00
parent 872c0b719d
commit cc6cdac9c0
Signed by: erwin
GPG key ID: 5D2F7887C661DEBD
11 changed files with 671 additions and 13 deletions

View file

@ -65,7 +65,8 @@
];
}];
in {
in
{
homeManagerConfigurations = {
erwin = user.mkHMUser {
userConfig = {
@ -74,6 +75,7 @@
applications.enable = true;
gpg.enable = true;
fish.enable = true;
sway.enable = true;
};
username = "erwin";
};

View file

@ -1,8 +1,10 @@
{ pkgs, config, lib, modulesPath, ... }:
with lib;
let cfg = config.eb.boot;
in {
let
cfg = config.eb.boot;
in
{
options.eb.boot = {
type = mkOption {
description = "Type of boot. Default bios.";
@ -10,10 +12,8 @@ in {
type = types.enum [ "bios" "uefi" ];
};
qemu = mkOption {
qemu = mkEnableOption {
description = "Set to true if running in qemu";
default = false;
type = types.bool;
};
grubInstallDevice = mkOption {
@ -80,6 +80,7 @@ in {
};
services.qemuGuest.enable = true;
services.spice-vdagentd.enable = true;
})
];
}

View file

@ -3,7 +3,8 @@ with lib;
let
cfg = config.eb.core;
in {
in
{
options.eb.core = {
enable = mkOption {
description = "Enable core options";
@ -26,7 +27,6 @@ in {
console = {
font = "Lat2-Terminus16";
keyMap = "colemak";
};
i18n.defaultLocale = "en_US.UTF-8";
@ -65,5 +65,9 @@ in {
services.openssh.enable = true;
hardware.opengl = {
enable = true;
driSupport = true;
};
};
}

View file

@ -0,0 +1,85 @@
{
enable = true;
settings = {
window = {
decorations = "full";
startup_mode = "Maximized";
};
scrolling = {
history = 100000;
};
font = {
normal = {
family = "CaskaydiaCove Nerd Font";
style = "Medium";
};
size = 10.0;
};
colors = {
primary = {
background = "#2e3440";
foreground = "#d8dee9";
dim_foreground = "#a5abb6";
};
cursor = {
text = "#2e3440";
cursor = "#d8dee9";
};
vi_mode_cursor = {
text = "#2e3440";
cursor = "#d8dee9";
};
selection = {
text = "CellForeground";
background = "#4c566a";
};
search = {
matches = {
foreground = "CellBackground";
background = "#88c0d0";
};
bar = {
background = "#434c5e";
foreground = "#d8dee9";
};
};
normal = {
black = "#3b4252";
red = "#bf616a";
green = "#a3be8c";
yellow = "#ebcb8b";
blue = "#81a1c1";
magenta = "#b48ead";
cyan = "#88c0d0";
white = "#e5e9f0";
};
bright = {
black = "#4c566a";
red = "#bf616a";
green = "#a3be8c";
yellow = "#ebcb8b";
blue = "#81a1c1";
magenta = "#b48ead";
cyan = "#8fbcbb";
white = "#eceff4";
};
dim = {
black = "#373e4d";
red = "#94545d";
green = "#809575";
yellow = "#b29e75";
blue = "#68809a";
magenta = "#8c738c";
cyan = "#6d96a5";
white = "#aeb3bb";
};
background_opacity = 0.9;
live_config_reload = true;
mouse = {
hide_when_typing = true;
};
};
};
}

View file

@ -3,7 +3,8 @@ with lib;
let
cfg = config.erwin.applications;
in {
in
{
options.erwin.applications = {
enable = mkOption {
description = "Enable a set of common applications";
@ -19,8 +20,17 @@ in {
home.packages = with pkgs; [
neovim
(nerdfonts.override { fonts = [ "CascadiaCode" "FantasqueSansMono" "FiraCode" "JetBrainsMono" "Meslo" "Noto" "SourceCodePro" ]; })
];
fonts.fontconfig.enable = true;
xdg = {
enable = true;
};
programs = {
alacritty = import ./alacritty.nix;
};
};
}

View file

@ -7,5 +7,6 @@
./git
./gpg
./ssh
./sway
];
}

View file

@ -4,10 +4,8 @@ with lib;
let cfg = config.erwin.fish;
in {
options.erwin.fish = {
enable = mkOption {
enable = mkEnableOption {
description = "Enable fish shell";
type = types.bool;
default = false;
};
};

View file

@ -0,0 +1,44 @@
{ pkgs, config, lib, ... }:
with lib;
let cfg = config.erwin.sway;
in
{
options.erwin.sway = {
enable = mkEnableOption {
description = "Enable sway";
};
};
config = mkIf (cfg.enable) {
wayland.windowManager.sway = {
enable = true;
config = import ./sway.nix {
inherit pkgs config lib;
};
extraSessionCommands =
''
export _JAVA_AWT_WM_NONREPARENTING=1
export MOZ_ENABLE_WAYLAND=1
export MOZ_DBUS_REMOTE=1
export QT_QPA_PLATFORM=wayland
export QT_WAYLAND_DISABLE_WINDOWDECORATION="1"
export QT_QPA_PLATFORMTHEME=qt5ct
export SDL_VIDEODRIVER=wayland
export SSH_AUTH_SOCK="''${XDG_RUNTIME_DIR}/gnupg/S.gpg-agent.ssh"
'';
wrapperFeatures = {
base = true;
gtk = true;
};
xwayland = true;
};
programs.waybar = import ./waybar.nix { inherit pkgs config lib; };
home.file.".wallpapers".source = ./wallpapers;
};
}

157
modules/users/sway/sway.nix Normal file
View file

@ -0,0 +1,157 @@
{ pkgs, config, lib, ... }:
let
cfg = config.wayland.windowManager.sway;
mod = "Mod4";
swaylockcmd = "${pkgs.swaylock}/bin/swaylock --ignore-empty-password --daemonize --show-failed-attempts --indicator-caps-lock --clock --image /home/erwin/Dropbox/Private/Wallpapers/2560x1440/arch.png --fade-in 0.5 --scaling fill";
in
{
modifier = mod;
assigns = {
"1" = [{ app_id = "firefox"; }];
"2" = [{ app_id = "Alacritty"; }];
"3" = [{ class = "Code"; }];
"10" = [{ class = "telegramdesktop"; } { class = "Signal"; }];
};
bars = [
{
command = "${pkgs.waybar}/bin/waybar";
}
];
left = "n";
down = "e";
up = "i";
right = "o";
floating = {
criteria = [{ app_id = "gnome-calculator"; }];
modifier = mod;
};
fonts = {
names = [ "MesloLGM Nerd Font" ];
style = "Regular";
size = 12.0;
};
gaps = {
inner = 10;
outer = 5;
smartBorders = "on";
};
input = {
"36125:40349:splitKB_Kyria" = {
xkb_options = "lv3:ralt_switch";
};
"1133:49291:Logitech_G502_HERO_SE" = {
natural_scroll = "enabled";
};
};
output = {
"Virtual-1" = {
bg = "~/.wallpapers/river-1920.png fill";
mode = "1920x1080@60Hz";
};
};
menu = "${pkgs.wofi}/bin/wofi --show drun -i | ${pkgs.findutils}/bin/xargs swaymsg exec --";
keybindings = {
"${cfg.config.modifier}+Return" = "exec ${cfg.config.terminal}";
"${cfg.config.modifier}+Shift+q" = "kill";
"${mod}+s" = "exec ${cfg.config.menu}";
"${mod}+Shift+s" = "exec ${pkgs.wofi}/bin/wofi --show run | ${pkgs.findutils}/bin/xargs swaymsg exec --";
"${cfg.config.modifier}+${cfg.config.left}" = "focus left";
"${cfg.config.modifier}+${cfg.config.down}" = "focus down";
"${cfg.config.modifier}+${cfg.config.up}" = "focus up";
"${cfg.config.modifier}+${cfg.config.right}" = "focus right";
"${cfg.config.modifier}+Left" = "focus left";
"${cfg.config.modifier}+Down" = "focus down";
"${cfg.config.modifier}+Up" = "focus up";
"${cfg.config.modifier}+Right" = "focus right";
"${cfg.config.modifier}+Shift+${cfg.config.left}" = "move left";
"${cfg.config.modifier}+Shift+${cfg.config.down}" = "move down";
"${cfg.config.modifier}+Shift+${cfg.config.up}" = "move up";
"${cfg.config.modifier}+Shift+${cfg.config.right}" = "move right";
"${cfg.config.modifier}+Shift+Left" = "move left";
"${cfg.config.modifier}+Shift+Down" = "move down";
"${cfg.config.modifier}+Shift+Up" = "move up";
"${cfg.config.modifier}+Shift+Right" = "move right";
"${mod}+h" = "split h";
"${mod}+v" = "split v";
"${mod}+t" = "fullscreen toggle";
"${cfg.config.modifier}+a" = "focus parent";
"${mod}+r" = "layout stacking";
"${cfg.config.modifier}+w" = "layout tabbed";
"${mod}+f" = "layout toggle split";
"${cfg.config.modifier}+Shift+space" = "floating toggle";
"${cfg.config.modifier}+space" = "focus mode_toggle";
"${cfg.config.modifier}+1" = "workspace number 1";
"${cfg.config.modifier}+2" = "workspace number 2";
"${cfg.config.modifier}+3" = "workspace number 3";
"${cfg.config.modifier}+4" = "workspace number 4";
"${cfg.config.modifier}+5" = "workspace number 5";
"${cfg.config.modifier}+6" = "workspace number 6";
"${cfg.config.modifier}+7" = "workspace number 7";
"${cfg.config.modifier}+8" = "workspace number 8";
"${cfg.config.modifier}+9" = "workspace number 9";
"${cfg.config.modifier}+Shift+1" =
"move container to workspace number 1";
"${cfg.config.modifier}+Shift+2" =
"move container to workspace number 2";
"${cfg.config.modifier}+Shift+3" =
"move container to workspace number 3";
"${cfg.config.modifier}+Shift+4" =
"move container to workspace number 4";
"${cfg.config.modifier}+Shift+5" =
"move container to workspace number 5";
"${cfg.config.modifier}+Shift+6" =
"move container to workspace number 6";
"${cfg.config.modifier}+Shift+7" =
"move container to workspace number 7";
"${cfg.config.modifier}+Shift+8" =
"move container to workspace number 8";
"${cfg.config.modifier}+Shift+9" =
"move container to workspace number 9";
"${cfg.config.modifier}+Shift+minus" = "move scratchpad";
"${cfg.config.modifier}+minus" = "scratchpad show";
"${cfg.config.modifier}+Shift+c" = "reload";
"${mod}+Shift+p" = "restart";
"${mod}+Shift+f" = "exec --no-startup-id ~/.config/wofi/session.sh";
"${mod}+l" = "exec ${swaylockcmd}";
"${mod}+p" = "mode resize";
"${mod}+Print" = "exec grim -o $(swaymsg -t get_outputs | ${pkgs.jq}/bin/jq -r '.[] | select(.focused) | .name')";
"${mod}+Shift+Print" = "exec grim -o $(swaymsg -t get_outputs | ${pkgs.jq}/bin/jq -r '.[] | select(.focused) | .name') - | ${pkgs.wl-clipboard}/bin/wl-copy -t \"image/png\" -f";
"${mod}+Shift+Ctrl+Print" = "exec grim -g \"$(${pkgs.slurp}/bin/slurp)\" - | ${pkgs.wl-clipboard}/bin/wl-copy -t \"image/png\" -f";
"${mod}+Shift+Alt+Print" = "exec grim -g \"$(${pkgs.slurp}/bin/slurp)\"";
"XF86AudioRaiseVolume" = "exec pamixer -ui 2 && pamixer --get-volume > $SWAYSOCK.wob";
"XF86AudioLowerVolume" = "exec pamixer -ud 2 && pamixer --get-volume > $SWAYSOCK.wob";
"XF86AudioMute" = "exec pamixer --toggle-mute && ( pamixer --get-mute && echo 0 > $SWAYSOCK.wob ) || pamixer --get-volume > $SWAYSOCK.wob";
"XF86Calculator" = "exec ${pkgs.gnome.gnome-calculator}/bin/gnome-calculator";
};
terminal = "${pkgs.alacritty}/bin/alacritty";
window = {
border = 1;
titlebar = false;
};
workspaceAutoBackAndForth = true;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 MiB

View file

@ -0,0 +1,356 @@
{ pkgs, config, lib, ... }:
{
enable = true;
settings = [
{
layer = "top";
position = "top";
height = 30;
modules-left = [
"sway/workspaces"
"sway/mode"
# "custom/now_playing"
];
modules-center = [
"sway/window"
];
modules-right = [
"network"
"memory"
"cpu"
"temperature"
"custom/keyboard-layout"
"pulseaudio"
"tray"
"clock#date"
"clock#time"
"idle_inhibitor"
];
modules = {
"clock#time" = {
interval = 1;
format = "{:%H:%M:%S}";
tooltip = false;
};
"clock#date" = {
interval = 10;
format = " {:%e %b %Y}";
tooltip-format = "{:%e %B %Y}";
};
"cpu" = {
interval = 5;
format = " {usage}% ({load})";
states = {
warning = 70;
critical = 90;
};
};
"custom/keyboard-layout" = {
exec = "swaymsg -t get_inputs | grep -m1 'xkb_active_layout_name' | cut -d '\"' -f4";
interval = 30;
format = " {}"; # Icon: keyboard
# Signal sent by Sway key binding (~/.config/sway/key-bindings)
signal = 1; # SIGHUP
tooltip = false;
};
"memory" = {
interval = 5;
format = " {}%"; # Icon: memory
states = {
warning = 70;
critical = 90;
};
};
"network" = {
interval = 5;
format-wifi = " {essid} ({signalStrength}%)"; # Icon: wifi
format-ethernet = " {ifname}: {ipaddr}/{cidr}"; # Icon: ethernet
format-disconnected = " Disconnected";
tooltip-format = "{ifname}: {ipaddr}";
};
"sway/mode" = {
format = "<span style=\"italic\"> {}</span>"; # Icon: expand-arrows-alt
tooltip = false;
};
# TODO: package as nix thingy
# "custom/now_playing" = {
# exec = "${HOME}/.config/waybar/ha-now-playing --host home.datarift.nl --entity media_player.sonos_woonkamer --token eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiI5OWJmN2YyNWYyODc0ZmZhOWVhMTZiNGM1MTQyZmUzZiIsImlhdCI6MTYwMzIyMDAyMiwiZXhwIjoxOTE4NTgwMDIyfQ.dNfjPN-cYStiPrSO-PVArJdShMWl2rdDeo8AXr1byIY";
# format = " ♪ {}";
# interval = 2;
# on-click = "${HOME}/.config/waybar/ha-now-playing --host home.datarift.nl --entity media_player.sonos_woonkamer --token eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiI5OWJmN2YyNWYyODc0ZmZhOWVhMTZiNGM1MTQyZmUzZiIsImlhdCI6MTYwMzIyMDAyMiwiZXhwIjoxOTE4NTgwMDIyfQ.dNfjPN-cYStiPrSO-PVArJdShMWl2rdDeo8AXr1byIY play-pause";
# on-scroll-down = "${HOME}/.config/waybar/ha-now-playing --host home.datarift.nl --entity media_player.sonos_woonkamer --token eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiI5OWJmN2YyNWYyODc0ZmZhOWVhMTZiNGM1MTQyZmUzZiIsImlhdCI6MTYwMzIyMDAyMiwiZXhwIjoxOTE4NTgwMDIyfQ.dNfjPN-cYStiPrSO-PVArJdShMWl2rdDeo8AXr1byIY volume-up";
# on-scroll-up = "${HOME}/.config/waybar/ha-now-playing --host home.datarift.nl --entity media_player.sonos_woonkamer --token eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiI5OWJmN2YyNWYyODc0ZmZhOWVhMTZiNGM1MTQyZmUzZiIsImlhdCI6MTYwMzIyMDAyMiwiZXhwIjoxOTE4NTgwMDIyfQ.dNfjPN-cYStiPrSO-PVArJdShMWl2rdDeo8AXr1byIY volume-down";
# };
"sway/window" = {
format = "{}";
max-length = 120;
};
"sway/workspaces" = {
all-outputs = false;
disable-scroll = true;
format = "{icon} {name}";
format-icons = {
"1 =www" = "";
# Icon = firefox-browser
"2 =mail" = "";
# Icon = mail
"3 =editor" = "";
# Icon = code
"4 =terminals" = "";
# Icon = terminal
"5 =portal" = "";
# Icon = terminal
"urgent" = "";
"focused" = "";
"default" = "";
};
};
"pulseaudio" = {
#scroll-step = 1;
format = "{icon} {volume}%";
format-bluetooth = "{icon} {volume}%";
format-muted = "";
format-icons = {
headphones = "";
handsfree = "";
headset = "";
phone = "";
portable = "";
car = "";
default = [ "" "奔" "" ];
};
on-click = "pavucontrol";
};
"temperature" = {
hwmon-path = "/sys/class/hwmon/hwmon2/temp1_input";
critical-threshold = 80;
interval = 5;
format = "{icon} {temperatureC}°C";
format-icons = [
"" # Icon = temperature-empty
"" # Icon = temperature-quarter
"" # Icon = temperature-half
"" # Icon = temperature-three-quarters
"" # Icon = temperature-full
];
tooltip = true;
};
"tray" = {
icon-size = 21;
spacing = 10;
};
"idle_inhibitor" = {
format = "<span size=\"large\">{icon}</span>";
format-icons = {
activated = "";
deactivated = "";
};
};
};
}
];
style =
''
@keyframes blink-warning {
70% {
color: white;
}
to {
color: white;
background-color: orange;
}
}
@keyframes blink-critical {
70% {
color: white;
}
to {
color: white;
background-color: red;
}
}
* {
border: none;
border-radius: 0;
min-height: 0;
margin: 0;
padding: 0;
}
#waybar {
background: #323232;
color: white;
font-family: "MesloLGM Nerd Font", sans-serif;
font-size: 13px;
}
#battery,
#clock,
#cpu,
#custom-keyboard-layout,
#memory,
#mode,
#network,
#pulseaudio,
#temperature,
#tray,
#custom-now_playing,
#idle_inhibitor {
padding-left: 10px;
padding-right: 10px;
}
#battery {
animation-timing-function: linear;
animation-iteration-count: infinite;
animation-direction: alternate;
}
#battery.warning {
color: orange;
}
#battery.critical {
color: red;
}
#battery.warning.discharging {
animation-name: blink-warning;
animation-duration: 3s;
}
#battery.critical.discharging {
animation-name: blink-critical;
animation-duration: 2s;
}
#clock {
font-weight: bold;
}
#cpu {
/* No styles */
}
#cpu.warning {
color: orange;
}
#cpu.critical {
color: red;
}
#memory {
animation-timing-function: linear;
animation-iteration-count: infinite;
animation-direction: alternate;
}
#memory.warning {
color: orange;
}
#memory.critical {
color: red;
animation-name: blink-critical;
animation-duration: 2s;
}
#mode {
background: #64727D;
border-top: 2px solid white;
/* To compensate for the top border and still have vertical centering */
padding-bottom: 2px;
}
#network {
/* No styles */
}
#network.disconnected {
color: orange;
}
#pulseaudio {
/* No styles */
}
#pulseaudio.muted {
/* No styles */
}
#custom-spotify {
color: rgb(102, 220, 105);
}
#temperature {
/* No styles */
}
#temperature.critical {
color: red;
}
#tray {
/* No styles */
}
#window {
font-weight: bold;
}
#workspaces button {
border-top: 2px solid transparent;
/* To compensate for the top border and still have vertical centering */
padding-bottom: 2px;
padding-left: 10px;
padding-right: 10px;
color: #888888;
}
#workspaces button.focused {
border-color: #4c7899;
color: white;
background-color: #285577;
}
#workspaces button.urgent {
border-color: #c9545d;
color: #c9545d;
}
#idle_inhibitor {
background-color: transparent;
font-weight: bold;
}
#idle_inhibitor.activated {
background-color: #c9545d;
color: #ffffff;
}
#custom-now_playing {
font-weight: bold;
}
'';
}