Compare commits

...

6 Commits

Author SHA1 Message Date
Noah Masur
cc4296c416 move keybinds to sxhkd 2023-08-06 22:08:20 -04:00
Noah Masur
40491a315d start to add sway config 2023-08-06 22:08:20 -04:00
Noah Masur
3cecb8810c playing with custom gtk theme
still pretty ugly unfortunately
2023-08-06 18:07:47 -04:00
Noah Masur
af753153f1 fix: clicking mouse in rofi power menu 2023-08-06 18:06:50 -04:00
Noah Masur
d2afdd56ae gitcredentialhelper option renamed 2023-08-06 18:06:23 -04:00
Noah Masur
18fec1d058 add another mbsync ignorefile for polybar 2023-08-06 18:06:11 -04:00
15 changed files with 284 additions and 190 deletions

View File

@ -11,23 +11,10 @@
config = lib.mkIf (config.gui.enable && config.kitty.enable) {
# Set the Rofi-Systemd terminal for viewing logs
# Using optionalAttrs because only available in NixOS
environment = { } // lib.attrsets.optionalAttrs
(builtins.hasAttr "sessionVariables" config.environment) {
sessionVariables.ROFI_SYSTEMD_TERM = "${pkgs.kitty}/bin/kitty";
};
terminal = "${pkgs.kitty}/bin/kitty";
home-manager.users.${config.user} = {
# Set the i3 terminal
xsession.windowManager.i3.config.terminal =
lib.mkIf pkgs.stdenv.isLinux "kitty";
# Set the Rofi terminal for running programs
programs.rofi.terminal =
lib.mkIf pkgs.stdenv.isLinux "${pkgs.kitty}/bin/kitty";
# Display images in the terminal
programs.fish.shellAliases = {
icat = "kitty +kitten icat";

View File

@ -44,7 +44,8 @@
# Better local mail search
programs.notmuch = {
enable = true;
new.ignore = [ ".mbsyncstate.lock" ".mbsyncstate.journal" ];
new.ignore =
[ ".mbsyncstate.lock" ".mbsyncstate.journal" ".mbsyncstate.new" ];
};
accounts.email = {

View File

@ -5,7 +5,7 @@
programs.gh =
lib.mkIf config.home-manager.users.${config.user}.programs.git.enable {
enable = true;
enableGitCredentialHelper = true;
gitCredentialHelper.enable = true;
settings.git_protocol = "https";
};

View File

@ -3,6 +3,7 @@
imports = [
./dunst.nix
./fonts.nix
./gtk.nix
./i3.nix
./picom.nix
./polybar.nix
@ -12,14 +13,6 @@
options = {
launcherCommand = lib.mkOption {
type = lib.types.str;
description = "Command to use for launching";
};
systemdSearch = lib.mkOption {
type = lib.types.str;
description = "Command to use for interacting with systemd";
};
altTabCommand = lib.mkOption {
type = lib.types.str;
description = "Command to use for choosing windows";
@ -36,14 +29,30 @@
type = lib.types.str;
description = "Command to use for quick calculations";
};
toggleBarCommand = lib.mkOption {
launcherCommand = lib.mkOption {
type = lib.types.str;
description = "Command to hide and show the status bar.";
description = "Command to use for launching";
};
lockScreenCommand = lib.mkOption {
type = lib.types.str;
description = "Command to use to lock the screen";
};
powerCommand = lib.mkOption {
type = lib.types.str;
description = "Command to use for power options menu";
};
systemdSearch = lib.mkOption {
type = lib.types.str;
description = "Command to use for interacting with systemd";
};
terminal = lib.mkOption {
type = lib.types.str;
description = "Package to use for graphical terminal";
};
toggleBarCommand = lib.mkOption {
type = lib.types.str;
description = "Command to hide and show the status bar.";
};
wallpaper = lib.mkOption {
type = lib.types.path;
description = "Wallpaper background image file";

View File

@ -0,0 +1,116 @@
{ config, pkgs, lib, ... }:
let
# Based on: https://gitlab.com/rycee/nur-expressions/-/blob/7ae92e3497e1f1805fb849510120e2ee393018cd/pkgs/materia-theme/default.nix
gtkTheme = pkgs.stdenv.mkDerivation rec {
pname = "materia-custom";
version = "20210322";
src = pkgs.fetchFromGitHub {
owner = "nana-4";
repo = "materia-theme";
rev = "v${version}";
sha256 = "1fsicmcni70jkl4jb3fvh7yv0v9jhb8nwjzdq8vfwn256qyk0xvl";
};
nativeBuildInputs = with pkgs; [
bc
optipng
sassc
(runCommandLocal "rendersvg" { } ''
mkdir -p $out/bin
ln -s ${resvg}/bin/resvg $out/bin/rendersvg
'')
];
dontConfigure = true;
# Fixes problem "Fontconfig error: Cannot load default config file"
FONTCONFIG_FILE =
pkgs.makeFontsConf { fontDirectories = [ pkgs.cantarell-fonts ]; };
# Derivation adds an extra # so we need to remove it from our colorscheme
theme = let stripHash = color: lib.strings.removePrefix "#" color;
in lib.generators.toKeyValue { } {
# Color selection copied from
# https://github.com/pinpox/nixos-home/blob/1cefe28c72930a0aed41c20d254ad4d193a3fa37/gtk.nix#L11
ACCENT_BG = stripHash config.theme.colors.base0B;
ACCENT_FG = stripHash config.theme.colors.base00;
BG = stripHash config.theme.colors.base00;
BTN_BG = stripHash config.theme.colors.base02;
BTN_FG = stripHash config.theme.colors.base06;
FG = stripHash config.theme.colors.base05;
HDR_BG = stripHash config.theme.colors.base02;
HDR_BTN_BG = stripHash config.theme.colors.base01;
HDR_BTN_FG = stripHash config.theme.colors.base05;
HDR_FG = stripHash config.theme.colors.base05;
MATERIA_SURFACE = stripHash config.theme.colors.base01;
MATERIA_VIEW = stripHash config.theme.colors.base01;
MENU_BG = stripHash config.theme.colors.base02;
MENU_FG = stripHash config.theme.colors.base06;
SEL_BG = stripHash config.theme.colors.base04;
SEL_FG = stripHash config.theme.colors.base05;
TXT_BG = stripHash config.theme.colors.base02;
TXT_FG = stripHash config.theme.colors.base07;
WM_BORDER_FOCUS = stripHash config.theme.colors.base03;
WM_BORDER_UNFOCUS = stripHash config.theme.colors.base02;
MATERIA_COLOR_VARIANT = if config.theme.dark then "dark" else "light";
MATERIA_STYLE_COMPACT = "True";
UNITY_DEFAULT_LAUNCHER_STYLE = "False";
};
passAsFile = [ "theme" ];
postPatch = ''
patchShebangs .
sed -e '/handle-horz-.*/d' -e '/handle-vert-.*/d' \
-i ./src/gtk-2.0/assets.txt
'';
buildPhase = ''
export HOME="$NIX_BUILD_ROOT"
./change_color.sh \
-i False \
-t $out/share/themes \
-o "materia-custom" \
"$themePath"
'';
};
in {
config = lib.mkIf config.gui.enable {
home-manager.users.${config.user} = {
gtk = let
gtkExtraConfig = {
gtk-application-prefer-dark-theme = config.theme.dark;
};
in {
enable = true;
theme = {
name = "materia-custom";
package = gtkTheme;
};
gtk3.extraConfig = gtkExtraConfig;
gtk4.extraConfig = gtkExtraConfig;
};
};
# Make the login screen dark
services.xserver.displayManager.lightdm.greeters.gtk.theme = {
name = config.home-manager.users.${config.user}.gtk.theme.name;
package = gtkTheme;
};
environment.sessionVariables = {
GTK_THEME = config.home-manager.users.${config.user}.gtk.theme.name;
};
};
}

View File

@ -2,8 +2,6 @@
let
lockCmd =
"${pkgs.betterlockscreen}/bin/betterlockscreen --lock --display 1 --blur 0.5 --span";
lockUpdate =
"${pkgs.betterlockscreen}/bin/betterlockscreen --update ${config.wallpaper} --display 1 --span";
@ -29,12 +27,6 @@ in {
ws2 = "2:II";
ws3 = "3:III";
ws4 = "4:IV";
ws5 = "5:V";
ws6 = "6:VI";
ws7 = "7:VII";
ws8 = "8:VIII";
ws9 = "9:IX";
ws10 = "10:X";
in {
modifier = modifier;
assigns = {
@ -92,118 +84,6 @@ in {
followMouse = false;
};
keybindings = {
# Adjust screen brightness
"Shift+F12" =
"exec ${pkgs.ddcutil}/bin/ddcutil --display 1 setvcp 10 + 30 && sleep 1; exec ${pkgs.ddcutil}/bin/ddcutil --display 2 setvcp 10 + 30";
"Shift+F11" =
"exec ${pkgs.ddcutil}/bin/ddcutil --display 1 setvcp 10 - 30 && sleep 1; exec ${pkgs.ddcutil}/bin/ddcutil --display 2 setvcp 10 - 30";
"XF86MonBrightnessUp" =
"exec ${pkgs.ddcutil}/bin/ddcutil --display 1 setvcp 10 + 30 && sleep 1; exec ${pkgs.ddcutil}/bin/ddcutil --display 2 setvcp 10 + 30";
"XF86MonBrightnessDown" =
"exec ${pkgs.ddcutil}/bin/ddcutil --display 1 setvcp 10 - 30 && sleep 1; exec ${pkgs.ddcutil}/bin/ddcutil --display 2 setvcp 10 - 30";
# Media player controls
"XF86AudioPlay" = "exec ${pkgs.playerctl}/bin/playerctl play-pause";
"XF86AudioStop" = "exec ${pkgs.playerctl}/bin/playerctl stop";
"XF86AudioNext" = "exec ${pkgs.playerctl}/bin/playerctl next";
"XF86AudioPrev" = "exec ${pkgs.playerctl}/bin/playerctl previous";
# Launchers
"${modifier}+Return" =
"exec --no-startup-id kitty; workspace ${ws2}; layout tabbed";
"${modifier}+space" =
"exec --no-startup-id ${config.launcherCommand}";
"${modifier}+Shift+s" =
"exec --no-startup-id ${config.systemdSearch}";
"${modifier}+Shift+a" =
"exec --no-startup-id ${config.audioSwitchCommand}";
"Mod1+Tab" = "exec --no-startup-id ${config.altTabCommand}";
"${modifier}+Shift+period" =
"exec --no-startup-id ${config.powerCommand}";
"${modifier}+Shift+m" =
"exec --no-startup-id ${config.brightnessCommand}";
"${modifier}+c" =
"exec --no-startup-id ${config.calculatorCommand}";
"${modifier}+Shift+c" = "reload";
"${modifier}+Shift+r" = "restart";
"${modifier}+Shift+q" = ''
exec "i3-nagbar -t warning -m 'You pressed the exit shortcut. Do you really want to exit i3? This will end your X session.' -B 'Yes, exit i3' 'i3-msg exit'"'';
"${modifier}+Shift+x" = "exec ${lockCmd}";
"${modifier}+Mod1+h" =
"exec --no-startup-id kitty sh -c '${pkgs.home-manager}/bin/home-manager switch --flake ${config.dotfilesPath}#${config.networking.hostName} || read'";
"${modifier}+Mod1+r" =
"exec --no-startup-id kitty sh -c 'doas nixos-rebuild switch --flake ${config.dotfilesPath}#${config.networking.hostName} || read'";
# Window options
"${modifier}+q" = "kill";
"${modifier}+b" = "exec ${config.toggleBarCommand}";
"${modifier}+f" = "fullscreen toggle";
"${modifier}+h" = "focus left";
"${modifier}+j" = "focus down";
"${modifier}+k" = "focus up";
"${modifier}+l" = "focus right";
"${modifier}+Left" = "focus left";
"${modifier}+Down" = "focus down";
"${modifier}+Up" = "focus up";
"${modifier}+Right" = "focus right";
"${modifier}+Shift+h" = "move left";
"${modifier}+Shift+j" = "move down";
"${modifier}+Shift+k" = "move up";
"${modifier}+Shift+l" = "move right";
"${modifier}+Shift+Left" = "move left";
"${modifier}+Shift+Down" = "move down";
"${modifier}+Shift+Up" = "move up";
"${modifier}+Shift+Right" = "move right";
# Tiling
"${modifier}+i" = "split h";
"${modifier}+v" = "split v";
"${modifier}+s" = "layout stacking";
"${modifier}+t" = "layout tabbed";
"${modifier}+e" = "layout toggle split";
"${modifier}+Shift+space" = "floating toggle";
"${modifier}+Control+space" = "focus mode_toggle";
"${modifier}+a" = "focus parent";
# Workspaces
"${modifier}+1" = "workspace ${ws1}";
"${modifier}+2" = "workspace ${ws2}";
"${modifier}+3" = "workspace ${ws3}";
"${modifier}+4" = "workspace ${ws4}";
"${modifier}+5" = "workspace ${ws5}";
"${modifier}+6" = "workspace ${ws6}";
"${modifier}+7" = "workspace ${ws7}";
"${modifier}+8" = "workspace ${ws8}";
"${modifier}+9" = "workspace ${ws9}";
"${modifier}+0" = "workspace ${ws10}";
# Move windows
"${modifier}+Shift+1" =
"move container to workspace ${ws1}; workspace ${ws1}";
"${modifier}+Shift+2" =
"move container to workspace ${ws2}; workspace ${ws2}";
"${modifier}+Shift+3" =
"move container to workspace ${ws3}; workspace ${ws3}";
"${modifier}+Shift+4" =
"move container to workspace ${ws4}; workspace ${ws4}";
"${modifier}+Shift+5" =
"move container to workspace ${ws5}; workspace ${ws5}";
"${modifier}+Shift+6" =
"move container to workspace ${ws6}; workspace ${ws6}";
"${modifier}+Shift+7" =
"move container to workspace ${ws7}; workspace ${ws7}";
"${modifier}+Shift+8" =
"move container to workspace ${ws8}; workspace ${ws8}";
"${modifier}+Shift+9" =
"move container to workspace ${ws9}; workspace ${ws9}";
"${modifier}+Shift+0" =
"move container to workspace ${ws10}; workspace ${ws10}";
# Move screens
"${modifier}+Control+l" = "move workspace to output right";
"${modifier}+Control+h" = "move workspace to output left";
# Resizing
"${modifier}+r" = ''mode "resize"'';
"${modifier}+Control+Shift+h" =
@ -232,6 +112,7 @@ in {
notification = false;
}
];
terminal = config.terminal;
window = {
border = 0;
hideEdgeBorders = "smart";
@ -239,22 +120,13 @@ in {
};
workspaceAutoBackAndForth = false;
workspaceOutputAssign = [ ];
# gaps = {
# bottom = 8;
# top = 8;
# left = 8;
# right = 8;
# horizontal = 15;
# vertical = 15;
# inner = 15;
# outer = 0;
# smartBorders = "off";
# smartGaps = false;
# };
};
extraConfig = "";
};
lockScreenCommand =
"${pkgs.betterlockscreen}/bin/betterlockscreen --lock --display 1 --blur 0.5 --span";
programs.fish.functions = {
update-lock-screen = lib.mkIf config.services.xserver.enable {
description = "Update lockscreen with wallpaper";
@ -278,14 +150,14 @@ in {
# Ref: https://github.com/betterlockscreen/betterlockscreen/blob/next/system/betterlockscreen%40.service
systemd.services.lock = {
enable = config.services.xserver.enable;
description = "Lock the screen on resume from suspend";
description = "Lock the screen before suspend";
before = [ "sleep.target" "suspend.target" ];
serviceConfig = {
User = config.user;
Type = "simple";
Environment = "DISPLAY=:0";
TimeoutSec = "infinity";
ExecStart = lockCmd;
ExecStart = config.lockScreenCommand;
ExecStartPost = "${pkgs.coreutils-full}/bin/sleep 1";
};
wantedBy = [ "sleep.target" "suspend.target" ];

View File

@ -0,0 +1,100 @@
{ config, pkgs, lib, ... }:
let
keybindings =
config.home-manager.users.${config.user}.programs.sxhkd.keybindings;
workspaceBindings = let
workspaces = {
"1" = "1:I";
"2" = "2:II";
"3" = "3:III";
"4" = "4:IV";
"5" = "5:V";
"6" = "6:VI";
"7" = "7:VII";
"8" = "8:VIII";
"9" = "9:IX";
"0" = "10:X";
};
# Create an attrset of keybinds to actions for every workspace by number
bindAll = keybindFunction: actionFunction:
(lib.genAttrs (map keybindFunction (builtins.attrNames workspaces))
actionFunction);
# Look up the name of the workspace based on its number
lookup = num: builtins.getAttr num workspaces;
in (bindAll (num: "super + ${num}")
(num: ''${pkgs.i3}/bin/i3-msg "workspace ${lookup num}"''))
// (bindAll (num: "super + shift + ${num}") (num:
''
${pkgs.i3}/bin/i3-msg "move container to workspace ${
lookup num
}; workspace ${lookup num}"''));
in {
home-manager.users.${config.user}.programs.sxhkd = {
enable = true;
keybindings = {
# Adjust screen brightness (TODO: replace with pkgs.light?)
"shift + {F11,F12}" = ''
${pkgs.ddcutil}/bin/ddcutil --display 1 setvcp 10 {- 30,+ 30} && sleep 1; \\
${pkgs.ddcutil}/bin/ddcutil --display 2 setvcp 10 {- 30,+ 30}
'';
"XF86MonBrightness{Down,Up}" = keybindings."shift + {F11,F12}";
# Media controls
"XF86Audio{Play,Stop,Next,Prev}" =
"${pkgs.playerctl}/bin/playerctl {play-pause,stop,next,previous}";
# Window management
"super + q" = ''${pkgs.i3}/bin/i3-msg "kill"'';
"super + b" = config.toggleBarCommand;
"super + f" = ''${pkgs.i3}/bin/i3-msg "fullscreen toggle"'';
"super + {h,j,k,l}" =
''${pkgs.i3}/bin/i3-msg "focus {left,down,up,right}"'';
"super + {Left,Down,Up,Right}" = keybindings."super + {h,j,k,l}";
"super + shift + {h,j,k,l}" =
''${pkgs.i3}/bin/i3-msg "move {left,down,up,right}"'';
"super + shift + {Left,Down,Up,Right}" =
keybindings."super + shift + {h,j,k,l}";
# Screen management
"super + control + l" =
''${pkgs.i3}/bin/i3-msg "move workspace to output right"'';
"super + control + h" =
''${pkgs.i3}/bin/i3-msg "move workspace to output left"'';
# Window layouts and tiling
"super + {i,v}" = ''${pkgs.i3}/bin/i3-msg "split {h,v}"'';
"super + {s,t,e}" =
''${pkgs.i3}/bin/i3-msg "layout {stacking,tabbed,toggle split}"'';
"super + shift + space" = ''${pkgs.i3}/bin/i3-msg "floating toggle"'';
"super + control + space" = ''${pkgs.i3}/bin/i3-msg "focus mode_toggle"'';
"super + a" = ''${pkgs.i3}/bin/i3-msg "focus parent"'';
# Launchers
"super + Return" = config.terminal;
"super + space" = config.launcherCommand;
"super + shift + s" = config.systemdSearch;
"super + shift + a" = config.audioSwitchCommand;
"alt + Tab" = config.altTabCommand;
"super + shift + period" = config.powerCommand;
"super + shift + m" = config.brightnessCommand;
"super + c" = config.calculatorCommand;
"super + shift + {c,r}" = ''${pkgs.i3}/bin/i3-msg "{reload,restart}"'';
"super + shift + x" = config.lockScreenCommand;
"super + alt + h" =
"${config.terminal} sh -c '${pkgs.home-manager}/bin/home-manager switch --flake ${config.dotfilesPath}#${config.networking.hostName} || read'";
"super + alt + r" =
"${config.terminal} sh -c 'doas nixos-rebuild switch --flake ${config.dotfilesPath}#${config.networking.hostName} || read'";
} // workspaceBindings;
};
}

View File

@ -1,6 +1,6 @@
{ config, pkgs, lib, ... }: {
config = lib.mkIf (pkgs.stdenv.isLinux && config.services.xserver.enable) {
config = lib.mkIf config.services.xserver.enable {
home-manager.users.${config.user} = {
services.picom = {

View File

@ -1,6 +1,6 @@
{ config, pkgs, lib, ... }: {
config = lib.mkIf (pkgs.stdenv.isLinux && config.services.xserver.enable) {
config = lib.mkIf config.services.xserver.enable {
toggleBarCommand = "polybar-msg cmd toggle";

View File

@ -8,11 +8,10 @@ in {
imports = [ ./rofi/power.nix ./rofi/brightness.nix ];
config = lib.mkIf (pkgs.stdenv.isLinux && config.services.xserver.enable) {
config = lib.mkIf config.services.xserver.enable {
# Set the Rofi-Systemd terminal for viewing logs
environment.sessionVariables.ROFI_SYSTEMD_TERM =
lib.mkIf config.kitty.enable "${pkgs.kitty}/bin/kitty";
environment.sessionVariables.ROFI_SYSTEMD_TERM = config.terminal;
home-manager.users.${config.user} = {
@ -24,6 +23,13 @@ in {
programs.rofi = {
enable = true;
cycle = true;
extraConfig = {
show-icons = true;
kb-cancel = "Escape,Super+space";
modi = "window,run,ssh,emoji,calc,systemd";
sort = true;
# levenshtein-sort = true;
};
location = "center";
pass = { };
plugins = [ pkgs.rofi-calc pkgs.rofi-emoji pkgs.rofi-systemd ];
@ -143,15 +149,9 @@ in {
};
};
terminal = config.terminal;
xoffset = 0;
yoffset = -20;
extraConfig = {
show-icons = true;
kb-cancel = "Escape,Super+space";
modi = "window,run,ssh,emoji,calc,systemd";
sort = true;
# levenshtein-sort = true;
};
};
home.file.".local/share/rofi/themes" = {

0
modules/nixos/graphical/rofi/brightness.nix Executable file → Normal file
View File

2
modules/nixos/graphical/rofi/power.nix Executable file → Normal file
View File

@ -25,7 +25,7 @@ in {
| ${rofi}/bin/rofi \
-theme-str '@import "power.rasi"' \
-hover-select \
-me-select-entry ''' \
-me-select-entry "" \
-me-accept-entry MousePrimary \
-dmenu \
-sep ';' \

View File

@ -32,7 +32,7 @@ done
chosen=$(printf '%s;%s\n' "$yes" "$no" |
rofi -theme-str '@import "prompt.rasi"' \
-hover-select \
-me-select-entry '' \
-me-select-entry "" \
-me-accept-entry MousePrimary \
-p "$query" \
-dmenu \

View File

@ -0,0 +1,25 @@
{ config, lib, ... }: {
config = lib.mkIf config.gui.enable {
programs.sway = {
enable = true;
package = null; # Use home-manager Sway instead
};
};
home-manager.users.${config.user} = {
wayland.windowManager.sway = {
enable = true;
config =
config.home-manager.users.${config.user}.xsession.windowManager.i3.config;
};
};
# TODO: swaybg
# TODO: swaylock
}

View File

@ -36,9 +36,6 @@
enable = config.services.xserver.enable;
background = config.wallpaper;
# Make the login screen dark
greeters.gtk.theme = gtkTheme;
# Show default user
# Also make sure /var/lib/AccountsService/users/<user> has SystemAccount=false
extraSeatDefaults = ''
@ -59,8 +56,6 @@
services.dbus.packages = [ pkgs.dconf ];
programs.dconf.enable = true;
environment.sessionVariables = { GTK_THEME = config.gtk.theme.name; };
home-manager.users.${config.user} = {
programs.fish.shellAliases = {
@ -68,17 +63,6 @@
pbpaste = "xclip -selection clipboard -out";
};
gtk = let
gtkExtraConfig = {
gtk-application-prefer-dark-theme = config.theme.dark;
};
in {
enable = true;
theme = gtkTheme;
gtk3.extraConfig = gtkExtraConfig;
gtk4.extraConfig = gtkExtraConfig;
};
};
};