Reorganized desktop, simplified systemwide setup
This commit is contained in:
1 parent
627c29ba9f
commit
9a5bd2177c
29 files changed
+295
-876
No files matched your search
@@ -0,0 +1,162 @@
|
||||
{
|
||||
lib,
|
||||
config,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
|
||||
with lib;
|
||||
let
|
||||
cfg = config.modules.waybar;
|
||||
theme = config.theming;
|
||||
colors = theme.colors;
|
||||
in
|
||||
{
|
||||
options.modules.waybar = {
|
||||
enable = mkEnableOption "waybar";
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
home.packages = with pkgs; [
|
||||
pulsemixer
|
||||
playerctl
|
||||
wpa_supplicant_gui # TODO: Move
|
||||
];
|
||||
|
||||
modules.desktop.reloadScript = ''
|
||||
# if ${pkgs.procps}/bin/pgrep waybar; then
|
||||
# ${pkgs.procps}/bin/pkill waybar
|
||||
# fi
|
||||
${pkgs.waybar}/bin/waybar &
|
||||
'';
|
||||
|
||||
programs.waybar = {
|
||||
enable = true;
|
||||
settings = {
|
||||
mainBar = {
|
||||
layer = "top";
|
||||
spacing = 16;
|
||||
modules-left = [ "river/tags" ];
|
||||
modules-center = [
|
||||
#"river/window"
|
||||
"mpris"
|
||||
];
|
||||
modules-right = [
|
||||
"bluetooth"
|
||||
"network"
|
||||
"pulseaudio"
|
||||
"battery"
|
||||
"clock"
|
||||
];
|
||||
"river/window" = {
|
||||
max-length = 50;
|
||||
};
|
||||
"river/tags" = {
|
||||
tag-labels = [
|
||||
"一"
|
||||
"二"
|
||||
"三"
|
||||
"四"
|
||||
"五"
|
||||
"六"
|
||||
"七"
|
||||
"八"
|
||||
"九"
|
||||
];
|
||||
disable-click = false;
|
||||
};
|
||||
network = {
|
||||
tooltip = false;
|
||||
on-click = "wpa_gui";
|
||||
format-wifi = "直 {essid}"; # Spacing achieved using "Thin Space"
|
||||
format-ethernet = "TODO";
|
||||
format-disconnected = "睊";
|
||||
};
|
||||
pulseaudio = {
|
||||
tooltip = false;
|
||||
format = "{icon} {volume}%"; # Spacing achieved using "Thin Space"
|
||||
#format-muted = "";
|
||||
format-muted = "{icon} --%"; # Spacing achieved using "Thin Space"
|
||||
format-icons = {
|
||||
#headphone = "";
|
||||
#default = [ "" "" ];
|
||||
headphone = "";
|
||||
headphone-muted = "";
|
||||
default = [
|
||||
""
|
||||
""
|
||||
""
|
||||
];
|
||||
};
|
||||
};
|
||||
battery = {
|
||||
format = "{icon} {capacity}%"; # Spacing achieved using "Thin Space"
|
||||
format-charging = " {capacity}%"; # Spacing achieved using "Thin Space"
|
||||
#format-icons = [ "" "" "" "" "" "" "" "" "" "" "" ];
|
||||
format-icons = [
|
||||
""
|
||||
""
|
||||
""
|
||||
""
|
||||
""
|
||||
""
|
||||
""
|
||||
""
|
||||
""
|
||||
""
|
||||
""
|
||||
];
|
||||
interval = 1;
|
||||
};
|
||||
clock = {
|
||||
#format = " {:%H:%M}";
|
||||
#format = " {:%H:%M}"; # Spacing achieved using "Thin Space"
|
||||
format = "{:%H:%M}";
|
||||
};
|
||||
mpris = {
|
||||
format = "{dynamic}";
|
||||
tooltip-format = "";
|
||||
interval = 1;
|
||||
};
|
||||
bluetooth = {
|
||||
tooltip = false;
|
||||
format = " {status}"; # Spacing achieved using "Thin Space"
|
||||
format-connected = " {device_alias}"; # Spacing achieved using "Thin Space"
|
||||
};
|
||||
};
|
||||
};
|
||||
# TODO: Replace base03 color with named color
|
||||
style = ''
|
||||
window#waybar {
|
||||
color: #${colors.fg};
|
||||
background-color: #${colors.bg};
|
||||
border-style: none none solid none;
|
||||
border-width: ${toString theme.layout.borderSize}px;
|
||||
border-color: #${colors.border-unfocused};
|
||||
font-size: 12px;
|
||||
font-family: "${theme.fonts.monospace.name}";
|
||||
}
|
||||
|
||||
.modules-right {
|
||||
margin: 0 8px 0 0;
|
||||
}
|
||||
|
||||
#tags button {
|
||||
color: #${theme.schemeColors.base03};
|
||||
padding: 0 5px 1px 5px;
|
||||
border-radius: 0;
|
||||
font-size: 16px;
|
||||
font-family: "wenquanyi bitmap song";
|
||||
}
|
||||
|
||||
#tags button.occupied {
|
||||
color: #${colors.fg};
|
||||
}
|
||||
|
||||
#tags button.focused {
|
||||
color: #${colors.accent};
|
||||
}
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
{
|
||||
lib,
|
||||
pkgs,
|
||||
config,
|
||||
...
|
||||
}:
|
||||
|
||||
with lib;
|
||||
let
|
||||
cfg = config.modules.desktop;
|
||||
in
|
||||
{
|
||||
imports = [
|
||||
# Import desktop environment modules
|
||||
./background/glpaper/default.nix
|
||||
./bar/waybar.nix
|
||||
./lock-screen/waylock.nix
|
||||
./window-manager/i3.nix
|
||||
./window-manager/river.nix
|
||||
];
|
||||
|
||||
options.modules.desktop = {
|
||||
wayland = mkEnableOption "wayland";
|
||||
# TODO: Remove, not needed with session/display manager
|
||||
initScript = mkOption {
|
||||
type = types.lines;
|
||||
default = "${pkgs.bash}/bin/bash";
|
||||
description = "Bash script to execute after logging in.";
|
||||
};
|
||||
# TODO: Find a nicer way to do this as this is also executed on startup
|
||||
reloadScript = mkOption {
|
||||
type = types.lines;
|
||||
default = "";
|
||||
description = "Shell script to execute after reload/rebuild.";
|
||||
};
|
||||
decorations = mkOption {
|
||||
type = types.nullOr (
|
||||
types.enum [
|
||||
"csd"
|
||||
"ssd"
|
||||
]
|
||||
);
|
||||
default = null;
|
||||
description = "Window decorations to use.";
|
||||
};
|
||||
};
|
||||
|
||||
config =
|
||||
lib.recursiveUpdate
|
||||
{
|
||||
# Ensure desktop related systemd services (xdg) have access to session variables.
|
||||
systemd.user.sessionVariables = config.home.sessionVariables;
|
||||
|
||||
home.packages = optionals cfg.wayland (
|
||||
with pkgs;
|
||||
[
|
||||
wl-clipboard
|
||||
wtype
|
||||
grim
|
||||
slurp
|
||||
]
|
||||
);
|
||||
|
||||
home.activation = {
|
||||
customReloadScript = lib.hm.dag.entryAfter [ "writeBoundary" ] (
|
||||
''
|
||||
#!${pkgs.bash}/bin/bash
|
||||
''
|
||||
+ cfg.reloadScript
|
||||
);
|
||||
};
|
||||
|
||||
home.file.".initrc" = {
|
||||
enable = true;
|
||||
executable = true;
|
||||
text =
|
||||
''
|
||||
#!${pkgs.bash}/bin/bash
|
||||
|
||||
''
|
||||
+ cfg.initScript;
|
||||
};
|
||||
}
|
||||
(
|
||||
# TODO: Move to dedicated module within desktop or maybe theming?
|
||||
if cfg.decorations == null then
|
||||
{ }
|
||||
else
|
||||
{
|
||||
csd = { };
|
||||
ssd = { };
|
||||
}
|
||||
."${cfg.decorations}"
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
{
|
||||
lib,
|
||||
pkgs,
|
||||
config,
|
||||
...
|
||||
}:
|
||||
|
||||
with lib;
|
||||
let
|
||||
cfg = config.modules.waylock;
|
||||
in
|
||||
{
|
||||
options.modules.waylock = {
|
||||
enable = mkEnableOption "waylock";
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
home.packages = (with pkgs; [ waylock ]);
|
||||
|
||||
# Systemwide configuration
|
||||
systemwide = {
|
||||
security.pam.services.waylock = { };
|
||||
};
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
|
||||
let
|
||||
cfg = config.modules.i3;
|
||||
in
|
||||
{
|
||||
options.modules.i3.enable = lib.mkEnableOption "i3";
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
# Set desktop type to x11
|
||||
# modules.desktop.x11 = true;
|
||||
modules.rofi.enable = true;
|
||||
|
||||
modules.desktop.initScript = ''
|
||||
i3
|
||||
'';
|
||||
|
||||
xsession.windowManager.i3 = {
|
||||
enable = true;
|
||||
};
|
||||
|
||||
# Systemwide configuration
|
||||
systemwide = {
|
||||
services.xserver = {
|
||||
layout = "us";
|
||||
xkbVariant = "";
|
||||
enable = true;
|
||||
windowManager.i3.enable = true;
|
||||
desktopManager = {
|
||||
xterm.enable = true;
|
||||
xfce = {
|
||||
enable = true;
|
||||
# noDesktop = false;
|
||||
# enableXfwm = false;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,264 @@
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
|
||||
let
|
||||
cfg = config.modules.river;
|
||||
in
|
||||
{
|
||||
options.modules.river.enable = lib.mkEnableOption "river";
|
||||
|
||||
# osConfig = lib.mkIf cfg.enable {
|
||||
# programs.river.enable = true;
|
||||
# };
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
# Set desktop type to wayland
|
||||
modules.desktop.wayland = true;
|
||||
|
||||
# TODO: Move elsewhere and make keybindings more configurable
|
||||
modules.rofi.enable = true;
|
||||
|
||||
# TODO: Move elsewhere
|
||||
home.packages = with pkgs; [
|
||||
brightnessctl
|
||||
river-filtile
|
||||
# owm
|
||||
|
||||
udiskie # TODO: Move to USB module
|
||||
];
|
||||
|
||||
# Change desktop to execute river
|
||||
modules.desktop.initScript = ''
|
||||
river
|
||||
'';
|
||||
|
||||
# Systemwide configuration
|
||||
systemwide = {
|
||||
programs.river.enable = true;
|
||||
};
|
||||
|
||||
# TODO: Fix this
|
||||
# modules.desktop.reloadScript = ''
|
||||
# ${pkgs.river}/bin/riverctl background-color 0x${config.theming.colors.bg}
|
||||
# '';
|
||||
|
||||
# Update background after rebuild
|
||||
# home.activation = {
|
||||
# river = lib.hm.dag.entryBetween [ "reloadSystemd" ] [ "installPackages" ] ''
|
||||
# # Close waybar
|
||||
# PATH="${pkgs.procps}/bin:$PATH" $DRY_RUN_CMD pkill waybar
|
||||
|
||||
# # Kill rivertile
|
||||
# PATH="${pkgs.procps}/bin:$PATH" $DRY_RUN_CMD pkill rivertile
|
||||
|
||||
# # Kill glpaper
|
||||
# PATH="${pkgs.procps}/bin:$PATH" $DRY_RUN_CMD pkill glpaper
|
||||
|
||||
# # Restart river
|
||||
# PATH="${pkgs.river}/bin:${pkgs.systemd}/bin:${pkgs.waybar}/bin:$PATH" $DRY_RUN_CMD ~/.config/river/init
|
||||
# '';
|
||||
# };
|
||||
|
||||
# River setup
|
||||
wayland.windowManager.river = {
|
||||
enable = true;
|
||||
xwayland.enable = false;
|
||||
settings =
|
||||
let
|
||||
layout = "filtile";
|
||||
layoutOptions = "-outer-padding ${toString config.theming.layout.windowPadding} -view-padding ${toString config.theming.layout.windowPadding} -main-ratio 0.5";
|
||||
modes = [
|
||||
"normal"
|
||||
"locked"
|
||||
];
|
||||
tags = [
|
||||
1
|
||||
2
|
||||
3
|
||||
4
|
||||
5
|
||||
6
|
||||
7
|
||||
8
|
||||
9
|
||||
];
|
||||
waylockOptions = "-init-color 0x${colors.bg} -input-color 0x${colors.border-focused} -fail-color 0x${colors.bg}";
|
||||
|
||||
colors = config.theming.colors;
|
||||
|
||||
# Quick pow function
|
||||
pow2 = power: if power != 0 then 2 * (pow2 (power - 1)) else 1;
|
||||
|
||||
# Modifiers
|
||||
main = "Super";
|
||||
ssm = "Super+Shift";
|
||||
sas = "Super+Alt+Shift";
|
||||
sam = "Super+Alt";
|
||||
scm = "Super+Control";
|
||||
scam = "Super+Control+Alt";
|
||||
ssc = "Super+Shift+Control";
|
||||
in
|
||||
{
|
||||
default-layout = "${layout}";
|
||||
set-repeat = "50 300";
|
||||
xcursor-theme = "BreezeX-RosePine-Linux 24";
|
||||
keyboard-layout = "-options \"caps:escape\" us";
|
||||
|
||||
border-width = toString config.theming.layout.borderSize;
|
||||
background-color = "0x${colors.bg}";
|
||||
border-color-focused = "0x${colors.fg}";
|
||||
border-color-unfocused = "0x${colors.border-unfocused}"; # TODO: Change to use named color;
|
||||
border-color-urgent = "0x${colors.fg}";
|
||||
|
||||
# TODO: Make a desktop options for DE applications
|
||||
spawn = [
|
||||
"\"${layout} ${layoutOptions}\""
|
||||
"waybar" # TODO: Decouple
|
||||
"\"glpaper eDP-1 ${toString config.modules.glpaper.shader}\""
|
||||
"udiskie"
|
||||
];
|
||||
map = (
|
||||
lib.attrsets.recursiveUpdate
|
||||
{
|
||||
"-repeat".normal = {
|
||||
# Basic utilities
|
||||
"${main} Q" = "close";
|
||||
"${ssm} Return" = "spawn foot";
|
||||
|
||||
# Window focus
|
||||
"${main} J" = "focus-view next";
|
||||
"${main} K" = "focus-view previous";
|
||||
|
||||
# Swap windows
|
||||
"${ssm} J" = "swap next";
|
||||
"${ssm} K" = "swap previous";
|
||||
"${main} Return" = "zoom";
|
||||
|
||||
# Main ratio
|
||||
"${main} H" = "send-layout-cmd ${layout} 'main-ratio -0.05'";
|
||||
"${main} L" = "send-layout-cmd ${layout} 'main-ratio +0.05'";
|
||||
|
||||
# Main count
|
||||
"${ssm} H" = "send-layout-cmd ${layout} 'main-count +1'";
|
||||
"${ssm} L" = "send-layout-cmd ${layout} 'main-count -1'";
|
||||
|
||||
# Move floating windows
|
||||
"${sam} H" = "move left 100";
|
||||
"${sam} J" = "move down 100";
|
||||
"${sam} K" = "move up 100";
|
||||
"${sam} L" = "move right 100";
|
||||
|
||||
# Resize floating windows
|
||||
"${sas} H" = "resize horizontal -100";
|
||||
"${sas} J" = "resize vertical 100";
|
||||
"${sas} K" = "resize vertical -100";
|
||||
"${sas} L" = "resize horizontal 100";
|
||||
|
||||
# Toggle modes
|
||||
"${main} Space" = "toggle-float";
|
||||
"${main} F" = "toggle-fullscreen";
|
||||
};
|
||||
normal =
|
||||
{
|
||||
# Basic utilities
|
||||
"${ssm} E" = "exit";
|
||||
"${main} X " = "spawn \"waylock -fork-on-lock ${waylockOptions}\"";
|
||||
"${main} P" = "spawn \"rofi -show drun\"";
|
||||
"${ssm} P" = "spawn rofi-rbw";
|
||||
"${main} S" =
|
||||
"spawn \"grim -g \\\"\\\$(slurp)\\\" ~/Images/Screenshots/\\\$(date +'%s_grim.png')\"";
|
||||
|
||||
# Tags
|
||||
"${main} 0" = "set-focused-tags ${toString (pow2 32 - 1)}";
|
||||
"${ssm} 0" = "set-view-tags ${toString (pow2 32 - 1)}";
|
||||
|
||||
# Orientation
|
||||
"${main} Up" = "send-layout-cmd ${layout} \"main-location top\"";
|
||||
"${main} Right" = "send-layout-cmd ${layout} \"main-location right\"";
|
||||
"${main} Down" = "send-layout-cmd ${layout} \"main-location bottom\"";
|
||||
"${main} Left" = "send-layout-cmd ${layout} \"main-location left\"";
|
||||
|
||||
# Snap floating windows
|
||||
"${scam} H" = "snap left";
|
||||
"${scam} J" = "snap down";
|
||||
"${scam} K" = "snap up";
|
||||
"${scam} L" = "snap right";
|
||||
}
|
||||
// builtins.listToAttrs (
|
||||
builtins.concatLists (
|
||||
map (tag: [
|
||||
{
|
||||
name = "${main} ${toString tag}";
|
||||
value = "set-focused-tags ${toString (pow2 (tag - 1))}";
|
||||
}
|
||||
{
|
||||
name = "${ssm} ${toString tag}";
|
||||
value = "set-view-tags ${toString (pow2 (tag - 1))}";
|
||||
}
|
||||
{
|
||||
name = "${scm} ${toString tag}";
|
||||
value = "toggle-focused-tags ${toString (pow2 (tag - 1))}";
|
||||
}
|
||||
{
|
||||
name = "${ssc} ${toString tag}";
|
||||
value = "toggle-view-tags ${toString (pow2 (tag - 1))}";
|
||||
}
|
||||
]) tags
|
||||
)
|
||||
);
|
||||
}
|
||||
(
|
||||
builtins.listToAttrs (
|
||||
map (mode: {
|
||||
name = "${mode}";
|
||||
value = {
|
||||
# Control volume
|
||||
"None XF86AudioRaiseVolume" = "spawn \"pulsemixer --change-volume +5\"";
|
||||
"None XF86AudioLowerVolume" = "spawn \"pulsemixer --change-volume -5\"";
|
||||
"None XF86AudioMute" = "spawn \"pulsemixer --toggle-mute\"";
|
||||
|
||||
# Control brightness
|
||||
"None XF86MonBrightnessUp" = "spawn \"brightnessctl set +5%\"";
|
||||
"None XF86MonBrightnessDown" = "spawn \"brightnessctl set 5%-\"";
|
||||
|
||||
# Control music playback
|
||||
"None XF86Messenger" = "spawn \"playerctl previous\"";
|
||||
"None XF86Go" = "spawn \"playerctl play-pause\"";
|
||||
"None Cancel" = "spawn \"playerctl next\"";
|
||||
};
|
||||
}) modes
|
||||
)
|
||||
)
|
||||
);
|
||||
map-pointer = {
|
||||
normal = {
|
||||
"${main} BTN_LEFT" = "move-view";
|
||||
"${main} BTN_RIGHT" = "resize-view";
|
||||
"${main} BTN_MIDDLE" = "toggle-float";
|
||||
};
|
||||
};
|
||||
input = {
|
||||
"'*'" = {
|
||||
accel-profile = "adaptive";
|
||||
pointer-accel = "0.5";
|
||||
scroll-factor = "0.8";
|
||||
};
|
||||
"'*Synaptics*'" = {
|
||||
natural-scroll = "enabled";
|
||||
};
|
||||
};
|
||||
rule-add = {
|
||||
"-app-id" = {
|
||||
"'bar'" = "csd";
|
||||
"'*'" = "ssd";
|
||||
"'wpa_gui'" = "float";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user