This commit is contained in:
Alejandro Angulo 2023-03-19 08:16:10 -07:00
parent fb20c45ead
commit d374a79f15
Signed by: alejandro-angulo
GPG key ID: 75579581C74554B6
6 changed files with 355 additions and 64 deletions

View file

@ -15,6 +15,9 @@ in {
config = mkIf cfg.enable { config = mkIf cfg.enable {
aa.desktop.addons.fonts.enable = true; aa.desktop.addons.fonts.enable = true;
# alacritty won't start without opengl
hardware.opengl.enable = true;
aa.home = { aa.home = {
extraOptions = { extraOptions = {
programs.alacritty = { programs.alacritty = {

View file

@ -0,0 +1,151 @@
{
options,
config,
pkgs,
lib,
...
}:
with lib; let
cfg = config.aa.desktop.addons.waybar;
in {
options.aa.desktop.addons.waybar = with types; {
enable = mkEnableOption "waybar";
};
config = mkIf cfg.enable {
aa.desktop.addons.fonts.enable = true;
aa.home = {
extraOptions = {
programs.waybar = {
enable = true;
systemd.enable = true;
style = builtins.readFile ./waybar_style.css;
settings = [
{
layer = "top";
position = "top";
height = 20;
modules-left = ["sway/workspaces"];
modules-center = ["clock"];
modules-right = [
"idle_inhibitor"
"temperature"
"cpu"
"pulseaudio"
"battery"
"memory"
"backlight"
"network"
"tray"
];
"sway/workspaces" = {
disable-scroll = false;
all-outputs = true;
format = "{icon}";
format-icons = {
"1" = "q";
"2" = "w";
"3" = "e";
"4" = "r";
"5" = "t";
"6" = "y";
"7" = "u";
"8" = "i";
"9" = "o";
urgent = " ";
focused = " ";
default = " ";
};
};
idle_inhibitor = {
format = "{icon}";
format-icons = {
activated = " ";
deactivated = " ";
};
};
temperature = {
critical-threshold = 80;
format = "{temperatureC}°C {icon}";
format-icons = [" " " " " "];
};
cpu = {
format = "{usage}% ";
tooltip = false;
};
pulseaudio = {
format = "{icon} {volume}% {format_source}";
format-bluetooth = "{icon} {volume}% {format_source}";
format-bluetooth-muted = " {volume}% {format_source}";
format-muted = " {format_source}";
format-source = " ";
format-source-muted = " ";
format-icons = {
headphone = " ";
hands-free = " ";
headset = " ";
phone = " ";
portable = " ";
car = " ";
default = [" " " " " "];
};
tooltip-format = "{desc}, {volume}%";
# TODO: Figure out how to get pactl binary?
on-click = "pactl set-sink-mute @DEFAULT_SINK@ toggle";
on-click-right = "pactl set-source-mute @DEFAULT_SOURCE@ toggle";
on-click-middle = "pavucontrol";
};
battery = {
states = {
warning = 30;
critical = 1;
};
format = "{icon} {capacity}%";
tooltip-format = "{timeTo}, {capacity}%";
format-charging = " {capacity}%";
format-plugged = " ";
format-alt = "{time} {icon}";
format-icons = ["" "" "" "" ""];
};
memory = {
format = "{}% ";
};
backlight = {
format = "{icon} {percent}%";
format-icons = [" " " "];
on-scroll-up = "light -A 1";
on-scroll-down = "light -U 1";
};
network = {
format-wifi = " ";
format-ethernet = "{ifname}: {ipaddr}/{cidr} ";
format-linked = "{ifname} (No IP) ";
format-disconnected = " ";
format-alt = "{ifname}: {ipaddr}/{cidr}";
tooltip-format = "{essid} {signalStrength}%";
};
tray = {
spacing = 10;
};
}
];
};
wayland.windowManager.sway.config.bars = [];
};
};
};
}

View file

@ -0,0 +1,132 @@
* {
border: none;
font-family: Hack Nerd Font, sans-serif;
font-size: 10px;
}
window#waybar {
background-color: rgba(29, 32, 33, 0.9);
border-bottom: 3px solid #1d2021;
color: #ffffdf;
transition-property: background-color;
transition-duration: .5s;
}
window#waybar.hidden {
opacity: 0.2;
}
#workspaces,
#mode,
#cpu,
#memory,
#temperature,
#clock,
#idle_inhibitor,
#language,
#pulseaudio,
#backlight,
#battery,
#network,
#tray {
background-color: #303030;
padding: 0 10px;
margin: 3px;
border: 3px solid rgba(0, 0, 0, 0);
border-radius: 90px;
background-clip: padding-box;
}
#workspaces button {
padding: 0 5px;
min-width: 20px;
color: #87afaf;
}
#workspaces button:hover {
background-color: rgba(0, 0, 0, 1)
}
#workspaces button.focused {
color: #ffaf00;
}
#workspaces button.urgent {
color: #e06c75;
}
#clock {
color: #61afef;
}
#idle_inhibitor {
color: #abb2bf;
}
#idle_inhibitor.activated {
background-color: #abb2bf;
color: #1e222a;
}
#temperature {
color: #fb4934;
}
#temperature.critical {
color: #1d2021;
background-color: #9d0006;
}
#cpu {
color: #ff8700;
}
#memory {
color: #87af87;
}
#battery {
color: #b8bb26;
}
#battery.charging, #battery.plugged {
background-color: #1f321c;
color: #ffffaf;
}
@keyframes blink {
to {
background-color: #1f321c;
color: #ffffaf;
}
}
#battery.critical:not(.charging) {
background-color: #afaf00;
color: #303030;
animation-name: blink;
animation-duration: 0.5s;
animation-timing-function: linear;
animation-iteration-count: infinite;
animation-direction: alternate;
}
#pulseaudio {
color: #fabd2f;
}
#pulseaudio.muted {
color: #b57614;
}
#backlight {
color: #17ccd5;
}
#network {
color: #d787af;
}
#network.disconnected {
color: #875f87;
}

View file

@ -8,7 +8,16 @@
with lib; let with lib; let
cfg = config.aa.desktop.sway; cfg = config.aa.desktop.sway;
nag = "swaynag"; nag = "swaynag";
sway_cfg = config.aa.home.extraOptions.wayland.windowManager.sway.config; left = "h";
right = "l";
up = "j";
down = "k";
modifier = "Mod4";
# TODO: This assume I'll be using rofi and alacritty. Should make more
# generic.
menu = "rofi -show run";
terminal = "alacritty";
in { in {
options.aa.desktop.sway = with types; { options.aa.desktop.sway = with types; {
enable = mkEnableOption "sway"; enable = mkEnableOption "sway";
@ -19,6 +28,7 @@ in {
alacritty.enable = true; alacritty.enable = true;
fonts.enable = true; fonts.enable = true;
rofi.enable = true; rofi.enable = true;
waybar.enable = true;
# TODO # TODO
# playerctl # playerctl
@ -33,16 +43,9 @@ in {
wrapperFeatures.gtk = true; # so that gtk works properly wrapperFeatures.gtk = true; # so that gtk works properly
config = { config = {
modifier = "Mod4"; inherit (terminal menu left right up down modifier);
terminal = "alacritty";
menu = "rofi -show run";
workspaceAutoBackAndForth = true; workspaceAutoBackAndForth = true;
left = "h";
right = "l";
up = "j";
down = "k";
colors = { colors = {
focused = { focused = {
border = "#2B3C44"; border = "#2B3C44";
@ -108,10 +111,10 @@ in {
# right will grow the containers width # right will grow the containers width
# up will shrink the containers height # up will shrink the containers height
# down will grow the containers height # down will grow the containers height
"${sway_cfg.left}" = "resize shrink width 50px"; "${left}" = "resize shrink width 50px";
"${sway_cfg.down}" = "resize grow height 50px"; "${down}" = "resize grow height 50px";
"${sway_cfg.up}" = "resize shrink height 50px"; "${up}" = "resize shrink height 50px";
"${sway_cfg.right}" = "resize grow width 50px"; "${right}" = "resize grow width 50px";
# Ditto, with arrow keys # Ditto, with arrow keys
"Left" = "resize shrink width 50px"; "Left" = "resize shrink width 50px";
@ -146,15 +149,15 @@ in {
keybindings = { keybindings = {
# Activate modes # Activate modes
"${sway_cfg.modifier}+s" = "mode resize"; "${modifier}+s" = "mode resize";
# Misc # Misc
"${sway_cfg.modifier}+Return" = "exec ${sway_cfg.terminal}"; "${modifier}+Return" = "exec ${terminal}";
"${sway_cfg.modifier}+c" = "kill"; "${modifier}+c" = "kill";
"${sway_cfg.modifier}+p" = "exec ${sway_cfg.menu}"; "${modifier}+p" = "exec ${menu}";
"${sway_cfg.modifier}+z" = "reload"; "${modifier}+z" = "reload";
# TODO: Reintroduce this. Failing because config.home.homeDirectory is not set # TODO: Reintroduce this. Failing because config.home.homeDirectory is not set
# "${sway_cfg.modifier}+x" = "exec swaylock -i ${config.home.homeDirectory}/dotfiles/users/alejandro/sway/wallpaper.png"; # "${modifier}+x" = "exec swaylock -i ${config.home.homeDirectory}/dotfiles/users/alejandro/sway/wallpaper.png";
# Volume control # Volume control
"XF86AudioRaiseVolume" = " exec 'pamixer --increase 5'"; "XF86AudioRaiseVolume" = " exec 'pamixer --increase 5'";
@ -165,10 +168,10 @@ in {
"XF86AudioPrev" = "exec 'playerctl previous'"; "XF86AudioPrev" = "exec 'playerctl previous'";
"XF86AudioNext" = "exec 'playerctl next'"; "XF86AudioNext" = "exec 'playerctl next'";
"XF86AudioPlay" = "exec 'playerctl play-pause'"; "XF86AudioPlay" = "exec 'playerctl play-pause'";
"${sway_cfg.modifier}+Down" = "exec 'playerctl pause'"; "${modifier}+Down" = "exec 'playerctl pause'";
"${sway_cfg.modifier}+Up" = "exec 'playerctl play'"; "${modifier}+Up" = "exec 'playerctl play'";
"${sway_cfg.modifier}+Right" = "exec 'playerctl next'"; "${modifier}+Right" = "exec 'playerctl next'";
"${sway_cfg.modifier}+Left" = "exec 'playerctl previous'"; "${modifier}+Left" = "exec 'playerctl previous'";
# Backlight keys # Backlight keys
"XF86MonBrightnessDown" = "exec 'light -U 5'"; "XF86MonBrightnessDown" = "exec 'light -U 5'";
@ -179,76 +182,76 @@ in {
## Focus ## Focus
### Move your focus around ### Move your focus around
"${sway_cfg.modifier}+${sway_cfg.left}" = "focus left"; "${modifier}+${left}" = "focus left";
"${sway_cfg.modifier}+${sway_cfg.down}" = "focus down"; "${modifier}+${down}" = "focus down";
"${sway_cfg.modifier}+${sway_cfg.up}" = "focus up"; "${modifier}+${up}" = "focus up";
"${sway_cfg.modifier}+${sway_cfg.right}" = "focus right"; "${modifier}+${right}" = "focus right";
### Move the focused window with the same, but add Shift ### Move the focused window with the same, but add Shift
"${sway_cfg.modifier}+Shift+${sway_cfg.left}" = "move left"; "${modifier}+Shift+${left}" = "move left";
"${sway_cfg.modifier}+Shift+${sway_cfg.down}" = "move down"; "${modifier}+Shift+${down}" = "move down";
"${sway_cfg.modifier}+Shift+${sway_cfg.up}" = "move up"; "${modifier}+Shift+${up}" = "move up";
"${sway_cfg.modifier}+Shift+${sway_cfg.right}" = "move right"; "${modifier}+Shift+${right}" = "move right";
## Workspaces ## Workspaces
### Switch to a workspace ### Switch to a workspace
"${sway_cfg.modifier}+q" = "workspace number 1"; "${modifier}+q" = "workspace number 1";
"${sway_cfg.modifier}+w" = "workspace number 2"; "${modifier}+w" = "workspace number 2";
"${sway_cfg.modifier}+e" = "workspace number 3"; "${modifier}+e" = "workspace number 3";
"${sway_cfg.modifier}+r" = "workspace number 4"; "${modifier}+r" = "workspace number 4";
"${sway_cfg.modifier}+t" = "workspace number 5"; "${modifier}+t" = "workspace number 5";
"${sway_cfg.modifier}+y" = "workspace number 6"; "${modifier}+y" = "workspace number 6";
"${sway_cfg.modifier}+u" = "workspace number 7"; "${modifier}+u" = "workspace number 7";
"${sway_cfg.modifier}+i" = "workspace number 8"; "${modifier}+i" = "workspace number 8";
"${sway_cfg.modifier}+o" = "workspace number 9"; "${modifier}+o" = "workspace number 9";
### Move focused container to workspace ### Move focused container to workspace
"${sway_cfg.modifier}+Shift+q" = "move container to workspace number 1"; "${modifier}+Shift+q" = "move container to workspace number 1";
"${sway_cfg.modifier}+Shift+w" = "move container to workspace number 2"; "${modifier}+Shift+w" = "move container to workspace number 2";
"${sway_cfg.modifier}+Shift+e" = "move container to workspace number 3"; "${modifier}+Shift+e" = "move container to workspace number 3";
"${sway_cfg.modifier}+Shift+r" = "move container to workspace number 4"; "${modifier}+Shift+r" = "move container to workspace number 4";
"${sway_cfg.modifier}+Shift+t" = "move container to workspace number 5"; "${modifier}+Shift+t" = "move container to workspace number 5";
"${sway_cfg.modifier}+Shift+y" = "move container to workspace number 6"; "${modifier}+Shift+y" = "move container to workspace number 6";
"${sway_cfg.modifier}+Shift+u" = "move container to workspace number 7"; "${modifier}+Shift+u" = "move container to workspace number 7";
"${sway_cfg.modifier}+Shift+i" = "move container to workspace number 8"; "${modifier}+Shift+i" = "move container to workspace number 8";
"${sway_cfg.modifier}+Shift+o" = "move container to workspace number 9"; "${modifier}+Shift+o" = "move container to workspace number 9";
# Layout # Layout
## Split direction ## Split direction
"${sway_cfg.modifier}+v" = "splith"; "${modifier}+v" = "splith";
"${sway_cfg.modifier}+g" = "splitv"; "${modifier}+g" = "splitv";
## Switch the current container between different layout styles ## Switch the current container between different layout styles
"${sway_cfg.modifier}+b" = "layout stacking"; "${modifier}+b" = "layout stacking";
"${sway_cfg.modifier}+n" = "layout tabbed"; "${modifier}+n" = "layout tabbed";
"${sway_cfg.modifier}+m" = "layout toggle split"; "${modifier}+m" = "layout toggle split";
## Make the current focus fullscreen ## Make the current focus fullscreen
"${sway_cfg.modifier}+f" = "fullscreen"; "${modifier}+f" = "fullscreen";
## move container between displays ## move container between displays
"${sway_cfg.modifier}+semicolon" = "move workspace to output right"; "${modifier}+semicolon" = "move workspace to output right";
## Toggle the current focus between tiling and floating mode ## Toggle the current focus between tiling and floating mode
"${sway_cfg.modifier}+Shift+f" = "floating toggle"; "${modifier}+Shift+f" = "floating toggle";
## Swap focus between the tiling area and the floating area ## Swap focus between the tiling area and the floating area
"${sway_cfg.modifier}+space" = "focus mode_toggle"; "${modifier}+space" = "focus mode_toggle";
## Move focus to the parent container ## Move focus to the parent container
"${sway_cfg.modifier}+a" = "focus parent"; "${modifier}+a" = "focus parent";
# Scratchpad # Scratchpad
# Move the currently focused window to the scratchpad # Move the currently focused window to the scratchpad
"${sway_cfg.modifier}+Shift+minus" = "move scratchpad"; "${modifier}+Shift+minus" = "move scratchpad";
# Show the next scratchpad window or hide the focused scratchpad window. # Show the next scratchpad window or hide the focused scratchpad window.
# If there are multiple scratchpad windows, this command cycles through them. # If there are multiple scratchpad windows, this command cycles through them.
"${sway_cfg.modifier}+minus" = "scratchpad show"; "${modifier}+minus" = "scratchpad show";
# Exit sway (logs you out of your Wayland session) # Exit sway (logs you out of your Wayland session)
"${sway_cfg.modifier}+Shift+z" = "exec ${nag} -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' 'swaymsg exit' -b 'Reload' 'swaymsg reload'"; "${modifier}+Shift+z" = "exec ${nag} -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' 'swaymsg exit' -b 'Reload' 'swaymsg reload'";
}; };
}; };
}; };

View file

@ -22,7 +22,7 @@ in {
configFile = mkOption { configFile = mkOption {
type = attrs; type = attrs;
default = {}; default = {};
description = "A set of files to be managed by home-manager's <option>xdf.configFile</option>."; description = "A set of files to be managed by home-manager's <option>xdg.configFile</option>.";
}; };
extraOptions = mkOption { extraOptions = mkOption {
type = attrs; type = attrs;

View file

@ -27,7 +27,9 @@ with lib; {
}; };
environment = { environment = {
systemPackages = with pkgs; [wayland-utils]; systemPackages = with pkgs; [
wayland-utils
];
variables = {"WLR_RENDERER_ALLOW_SOFTWARE" = "1";}; variables = {"WLR_RENDERER_ALLOW_SOFTWARE" = "1";};
}; };
} }