restructure x11
This commit is contained in:
parent
a4a16cc97c
commit
8b6dd79516
19 changed files with 406 additions and 312 deletions
46
home/modules/linux/graphical/alacritty.nix
Normal file
46
home/modules/linux/graphical/alacritty.nix
Normal file
|
@ -0,0 +1,46 @@
|
|||
{ pkgs, config, lib, ... }:
|
||||
|
||||
with lib;
|
||||
{
|
||||
programs.alacritty = mkIf (config.linux.graphical.type != null) {
|
||||
enable = true;
|
||||
package = pkgs.unstable.alacritty;
|
||||
|
||||
settings = {
|
||||
window.opacity = 0.95;
|
||||
font = {
|
||||
size = 14.0;
|
||||
normal.family = "Fantasque Sans Mono Nerd Font";
|
||||
};
|
||||
shell = {
|
||||
program = "/bin/sh";
|
||||
args = [ "-ic" "${config.programs.fish.package}/bin/fish" ];
|
||||
};
|
||||
colors = {
|
||||
# Default colors
|
||||
primary.background = "0xf1f1f1";
|
||||
primary.foreground = "0x424242";
|
||||
|
||||
# Normal colors
|
||||
normal.black = "0x212121";
|
||||
normal.red = "0xc30771";
|
||||
normal.green = "0x10a778";
|
||||
normal.yellow = "0xa89c14";
|
||||
normal.blue = "0x008ec4";
|
||||
normal.magenta = "0x523c79";
|
||||
normal.cyan = "0x20a5ba";
|
||||
normal.white = "0xe0e0e0";
|
||||
|
||||
# Bright colors
|
||||
bright.black = "0x212121";
|
||||
bright.red = "0xfb007a";
|
||||
bright.green = "0x5fd7af";
|
||||
bright.yellow = "0xf3e430";
|
||||
bright.blue = "0x20bbfc";
|
||||
bright.magenta = "0x6855de";
|
||||
bright.cyan = "0x4fb8cc";
|
||||
bright.white = "0xf1f1f1";
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
72
home/modules/linux/graphical/default.nix
Normal file
72
home/modules/linux/graphical/default.nix
Normal file
|
@ -0,0 +1,72 @@
|
|||
{ pkgs, lib, config, ... }:
|
||||
with lib;
|
||||
let
|
||||
cfg = config.linux.graphical;
|
||||
in
|
||||
{
|
||||
imports = [ ./x11.nix ./wayland.nix ./alacritty.nix ];
|
||||
options.linux.graphical = {
|
||||
type = mkOption {
|
||||
type = types.nullOr (types.enum [ "x11" "wayland" ]);
|
||||
description = "Enable linux graphical configurations, with either 'x11' or 'wayland'";
|
||||
default = null;
|
||||
};
|
||||
wallpaper = mkOption {
|
||||
type = types.oneOf [ types.str types.path ];
|
||||
description = "Path to the wallpaper file";
|
||||
default = "";
|
||||
};
|
||||
};
|
||||
config = mkIf (cfg.type != null) {
|
||||
# Packages
|
||||
|
||||
home.packages = (with pkgs; [
|
||||
## GUI stuff
|
||||
gnome.cheese # Webcam check
|
||||
evince # PDF reader
|
||||
gparted
|
||||
pkgs.unstable.vscode
|
||||
feh
|
||||
deluge # Torrent client
|
||||
mailspring
|
||||
unstable.discord
|
||||
pavucontrol # PulseAudio control panel
|
||||
|
||||
## CLI stuff
|
||||
dex # .desktop file management, startup
|
||||
sct # Display color temperature
|
||||
]);
|
||||
|
||||
# Cursor
|
||||
xsession.pointerCursor = {
|
||||
package = pkgs.numix-cursor-theme;
|
||||
name = "Numix-Cursor-Light";
|
||||
size = 32;
|
||||
};
|
||||
|
||||
# MIME set ups
|
||||
xdg.enable = true;
|
||||
xdg.mimeApps.enable = true;
|
||||
xdg.mimeApps.defaultApplications = {
|
||||
"x-scheme-handler/http" = [ "firefox.desktop" ];
|
||||
"x-scheme-handler/https" = [ "firefox.desktop" ];
|
||||
"x-scheme-handler/ftp" = [ "firefox.desktop" ];
|
||||
"x-scheme-handler/ftps" = [ "firefox.desktop" ];
|
||||
"x-scheme-handler/mailspring" = [ "Mailspring.desktop" ];
|
||||
};
|
||||
|
||||
home.sessionVariables = {
|
||||
# Set up Java font style
|
||||
_JAVA_OPTIONS = "-Dawt.useSystemAAFontSettings=lcd";
|
||||
};
|
||||
|
||||
# IBus configuration
|
||||
dconf.settings."desktop/ibus/general" = {
|
||||
engines-order = hm.gvariant.mkArray hm.gvariant.type.string [ "xkb:jp::jpn" "mozc-jp" "Bamboo" ];
|
||||
reload-engines = hm.gvariant.mkArray hm.gvariant.type.string [ "xkb:jp::jpn" "mozc-jp" "Bamboo" ];
|
||||
};
|
||||
dconf.settings."desktop/ibus/general/hotkey" = {
|
||||
triggers = hm.gvariant.mkArray hm.gvariant.type.string [ "<Super>z" ];
|
||||
};
|
||||
};
|
||||
}
|
28
home/modules/linux/graphical/wayland.nix
Normal file
28
home/modules/linux/graphical/wayland.nix
Normal file
|
@ -0,0 +1,28 @@
|
|||
{ pkgs, config, lib, ... }:
|
||||
with lib;
|
||||
{
|
||||
config = mkIf (config.linux.graphical.type == "wayland") {
|
||||
# Additional packages
|
||||
home.packages = with pkgs; [
|
||||
wl-clipboard # Clipboard management
|
||||
|
||||
# Mimic the clipboard stuff in MacOS
|
||||
(pkgs.writeShellScriptBin "pbcopy" ''
|
||||
exec ${pkgs.wl-clipboard}/bin/wl-copy
|
||||
'')
|
||||
(pkgs.writeShellScriptBin "pbpaste" ''
|
||||
exec ${pkgs.wl-clipboard}/bin/wl-paste -n
|
||||
'')
|
||||
];
|
||||
|
||||
# Notification system
|
||||
programs.mako = {
|
||||
enable = true;
|
||||
borderRadius = 5;
|
||||
};
|
||||
|
||||
# Forward wallpaper settings to sway
|
||||
programs.my-sway.wallpaper = config.linux.graphical.wallpaper;
|
||||
};
|
||||
}
|
||||
|
35
home/modules/linux/graphical/x11.nix
Normal file
35
home/modules/linux/graphical/x11.nix
Normal file
|
@ -0,0 +1,35 @@
|
|||
{ pkgs, config, lib, ... }:
|
||||
with lib;
|
||||
{
|
||||
imports = [ ./x11/hidpi.nix ./x11/i3.nix ];
|
||||
config = mkIf (config.linux.graphical.type == "x11") {
|
||||
# X Session settings
|
||||
xsession.enable = true;
|
||||
|
||||
# Additional packages
|
||||
home.packages = with pkgs; [
|
||||
xsel # Clipboard management
|
||||
|
||||
# Mimic the clipboard stuff in MacOS
|
||||
(pkgs.writeShellScriptBin "pbcopy" ''
|
||||
exec ${pkgs.xsel}/bin/xsel -ib
|
||||
'')
|
||||
(pkgs.writeShellScriptBin "pbpaste" ''
|
||||
exec ${pkgs.xsel}/bin/xsel -ob
|
||||
'')
|
||||
];
|
||||
|
||||
# Notification system
|
||||
services.X11.xfce4-notifyd.enable = true;
|
||||
|
||||
# Picom: X Compositor
|
||||
services.picom = {
|
||||
enable = true;
|
||||
blur = true;
|
||||
fade = true;
|
||||
fadeDelta = 3;
|
||||
shadow = true;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
31
home/modules/linux/graphical/x11/hidpi.nix
Normal file
31
home/modules/linux/graphical/x11/hidpi.nix
Normal file
|
@ -0,0 +1,31 @@
|
|||
{ pkgs, config, lib, ... }:
|
||||
|
||||
with lib;
|
||||
let
|
||||
cfg = config.linux.graphical.x11;
|
||||
in
|
||||
{
|
||||
options.linux.graphical.x11.hidpi = mkEnableOption "Enable hiDPI mode for X11";
|
||||
|
||||
config = mkIf cfg.hidpi {
|
||||
# X resources for 4k monitor
|
||||
home.file."4k.Xresources" = {
|
||||
target = ".config/X11/.Xresources";
|
||||
text = ''
|
||||
Xft.dpi: 192
|
||||
! These might also be useful depending on your monitor and personal preference:
|
||||
Xft.autohint: 0
|
||||
Xft.lcdfilter: lcddefault
|
||||
Xft.hintstyle: hintfull
|
||||
Xft.hinting: 1
|
||||
Xft.antialias: 1
|
||||
Xft.rgba: rgb
|
||||
'';
|
||||
};
|
||||
# Load 4k Xresources
|
||||
xsession.initExtra = ''
|
||||
xrdb -merge ~/.config/X11/.Xresources
|
||||
feh --bg-fill ~/wallpaper.jpg
|
||||
'';
|
||||
};
|
||||
}
|
153
home/modules/linux/graphical/x11/i3.nix
Normal file
153
home/modules/linux/graphical/x11/i3.nix
Normal file
|
@ -0,0 +1,153 @@
|
|||
{ pkgs, config, lib, ... }:
|
||||
|
||||
with lib;
|
||||
let
|
||||
cfg = config.linux.graphical.x11;
|
||||
|
||||
mod = "Mod4";
|
||||
workspaces = [
|
||||
"1: web"
|
||||
"2: chat"
|
||||
"3: code"
|
||||
"4: music"
|
||||
"5: extra"
|
||||
"6: 6"
|
||||
"7: 7"
|
||||
"8: 8"
|
||||
"9: 9"
|
||||
"10: 10"
|
||||
];
|
||||
wsAttrs = builtins.listToAttrs (
|
||||
map
|
||||
(i: { name = toString (remainder i 10); value = builtins.elemAt workspaces (i - 1); })
|
||||
(range 1 11)
|
||||
);
|
||||
remainder = x: y: x - (builtins.div x y) * y;
|
||||
range = from: to:
|
||||
let
|
||||
f = cur: if cur == to then [ ] else [ cur ] ++ f (cur + 1);
|
||||
in
|
||||
f from;
|
||||
in
|
||||
{
|
||||
imports = [ ./i3/screenshot.nix ];
|
||||
|
||||
options.linux.graphical.x11.enablei3 = mkEnableOption "Enable i3";
|
||||
|
||||
config = mkIf (cfg.enablei3) {
|
||||
|
||||
## i3 window manager
|
||||
xsession.windowManager.i3 = {
|
||||
enable = true;
|
||||
config.assigns = {
|
||||
"${wsAttrs."1"}" = [{ class = "^firefox$"; }];
|
||||
"${wsAttrs."2"}" = [{ class = "^discord$"; }];
|
||||
};
|
||||
config.bars = [{
|
||||
command = "${pkgs.i3-gaps}/bin/i3bar -t";
|
||||
statusCommand = "${pkgs.i3status-rust}/bin/i3status-rs ~/.config/i3status-rust/config-default.toml";
|
||||
position = "top";
|
||||
colors = {
|
||||
background = "#00000080";
|
||||
statusline = "#ffffff";
|
||||
separator = "#666666";
|
||||
|
||||
focusedWorkspace = { background = "#4c7899"; border = "#285577"; text = "#ffffff"; };
|
||||
activeWorkspace = { background = "#333333"; border = "#5f676a"; text = "#ffffff"; };
|
||||
inactiveWorkspace = { background = "#333333"; border = "#222222"; text = "#888888"; };
|
||||
urgentWorkspace = { background = "#2f343a"; border = "#900000"; text = "#ffffff"; };
|
||||
bindingMode = { background = "#2f343a"; border = "#900000"; text = "#ffffff"; };
|
||||
};
|
||||
}];
|
||||
config.focus.newWindow = "none";
|
||||
config.fonts = { names = [ "FantasqueSansMono Nerd Font Mono" "monospace" ]; size = 11.0; };
|
||||
config.gaps.outer = 5;
|
||||
config.gaps.inner = 5;
|
||||
config.gaps.smartGaps = true;
|
||||
config.modifier = mod;
|
||||
config.terminal = "alacritty";
|
||||
config.window.titlebar = false;
|
||||
|
||||
# Keybindings
|
||||
config.keybindings = lib.mkOptionDefault ({
|
||||
## vim-style movements
|
||||
"${mod}+h" = "focus left";
|
||||
"${mod}+j" = "focus down";
|
||||
"${mod}+k" = "focus up";
|
||||
"${mod}+l" = "focus right";
|
||||
"${mod}+Shift+h" = "move left";
|
||||
"${mod}+Shift+j" = "move down";
|
||||
"${mod}+Shift+k" = "move up";
|
||||
"${mod}+Shift+l" = "move right";
|
||||
## Splits
|
||||
"${mod}+v" = "split v";
|
||||
"${mod}+Shift+v" = "split h";
|
||||
## Run
|
||||
"${mod}+r" = "exec ${pkgs.dmenu}/bin/dmenu_run";
|
||||
"${mod}+d" = "exec i3-dmenu-desktop --dmenu='${pkgs.dmenu}/bin/dmenu -i'";
|
||||
} // (
|
||||
builtins.listToAttrs (lib.flatten (map
|
||||
(key: [
|
||||
{
|
||||
name = "${mod}+${key}";
|
||||
value = "workspace ${builtins.getAttr key wsAttrs}";
|
||||
}
|
||||
{
|
||||
name = "${mod}+Shift+${key}";
|
||||
value = "move to workspace ${builtins.getAttr key wsAttrs}";
|
||||
}
|
||||
])
|
||||
(builtins.attrNames wsAttrs))
|
||||
)));
|
||||
|
||||
# Workspace
|
||||
config.defaultWorkspace = "workspace ${builtins.getAttr "1" wsAttrs}";
|
||||
config.startup = [
|
||||
{ command = "firefox"; }
|
||||
{ command = "discord"; }
|
||||
{ command = "dex -ae i3"; }
|
||||
{ command = "ibus-daemon -drxR"; }
|
||||
];
|
||||
};
|
||||
|
||||
|
||||
# i3status
|
||||
programs.i3status-rust.enable = true;
|
||||
programs.i3status-rust.bars.default = {
|
||||
icons = "material-nf";
|
||||
theme = "native";
|
||||
settings = {
|
||||
icons_format = " <span font_family='FantasqueSansMono Nerd Font'>{icon}</span> ";
|
||||
};
|
||||
blocks = [
|
||||
# {
|
||||
# block = "bluetooth";
|
||||
# mac = "5C:52:30:D8:E2:9D";
|
||||
# format = "Airpods Pro {percentage}";
|
||||
# format_unavailable = "Airpods Pro XX";
|
||||
# }
|
||||
{
|
||||
block = "cpu";
|
||||
format = "{utilization}";
|
||||
}
|
||||
{
|
||||
block = "hueshift";
|
||||
}
|
||||
{
|
||||
block = "memory";
|
||||
}
|
||||
{
|
||||
block = "net";
|
||||
}
|
||||
{
|
||||
block = "sound";
|
||||
}
|
||||
{
|
||||
block = "time";
|
||||
}
|
||||
];
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
|
9
home/modules/linux/graphical/x11/i3/screenshot.nix
Normal file
9
home/modules/linux/graphical/x11/i3/screenshot.nix
Normal file
|
@ -0,0 +1,9 @@
|
|||
{ pkgs, config, lib, ... }:
|
||||
|
||||
with lib;
|
||||
{
|
||||
xsession.windowManager.i3.config = mkIf (config.linux.graphical.x11.enablei3) {
|
||||
startup = [{ command = "${pkgs.flameshot}/bin/flameshot"; }];
|
||||
keybindings = mkOptionDefault { "Print" = "exec ${pkgs.flameshot}/bin/flameshot gui"; };
|
||||
};
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue