move home-manager config to subdirectory

This commit is contained in:
Daniel Olsen
2024-08-17 03:17:40 +02:00
parent 08930ba021
commit a6f2ac0868
23 changed files with 1 additions and 7 deletions

View File

@@ -0,0 +1,188 @@
{ pkgs, config, lib, ... }:
let
cfg = config.profiles.xsession;
non-nixos = config.profiles.non-nixos;
mkGL = program: "${lib.strings.optionalString non-nixos.enable "${pkgs.nixgl.auto.nixGLDefault}/bin/nixGL "}${program}";
execScope = program: "exec bash -c \"systemd-run --user --scope --unit='app-i3-exec-$RANDOM' -p CollectMode=inactive-or-failed -p MemoryHigh=85% -p MemoryMax=92% -p MemorySwapMax=5G -p MemoryAccounting=true \"${program}\"\"";
in
{
imports = [ ./dunstrc.nix ./terminal.nix ./polybar.nix ];
options.profiles.xsession = {
enable = lib.mkEnableOption "Whether or not to control the xsession";
};
config = lib.mkIf cfg.enable {
profiles.gui.enable = true;
systemd.user.slices.app.Slice = {
MemoryHigh="90%";
MemoryMax="94%";
MemorySwapMax="8G";
CPUQuota="${toString ((config.machine.cores - 1)*100)}%";
MemoryAccounting = true;
};
home.keyboard = {
layout = "no";
variant = "nodeadkeys";
};
services.random-background = {
enable = false;
imageDirectory = "${pkgs.dan.wallpapers}";
interval = "30m";
};
services.dunst.enable = false;
xsession = {
enable = true;
initExtra = ''
export PATH="$HOME/.config/nixpkgs/nix-dotfiles/bin:$PATH"
export XDG_CURRENT_DESKTOP=kde
export DESKTOP_SESSION=kde
'';
windowManager = {
i3.enable = true;
i3.config = {
modifier = "Mod4";
terminal = "${pkgs.kitty}/bin/kitty";
keybindings = let
modifier = config.xsession.windowManager.i3.config.modifier;
dmenu = if config.machine.systemd then "${../../scripts/dmenu_run_systemd}" else "dmenu_run";
in lib.mkOptionDefault {
"${modifier}+0" = "workspace 10";
"${modifier}+Shift+0" = "move container to workspace 10";
"${modifier}+Tab" = "workspace next";
"${modifier}+Shift+Tab" = "workspace prev";
"XF86AudioRaiseVolume" = "exec --no-startup-id ${pkgs.pulseaudio}/bin/pactl set-sink-volume 0 +5%";
"XF86AudioLowerVolume" = "exec --no-startup-id ${pkgs.pulseaudio}/bin/pactl set-sink-volume 0 -5%";
"XF86AudioMute" = "exec --no-startup-id ${pkgs.pulseaudio}/bin/pactl set-sink-mute 0 toggle";
"XF86AudioMicMute" = "exec --no-startup-id ${pkgs.pulseaudio}/bin/pactl set-source-mute 1 toggle";
# Georg volume controls
"Shift+XF86AudioRaiseVolume" = "exec --no-startup-id ${lib.getExe pkgs.gregctl} set-volume -- +5%";
"Shift+XF86AudioLowerVolume" = "exec --no-startup-id ${lib.getExe pkgs.gregctl} set-volume -- -5%";
"Shift+XF86AudioMute" = "exec --no-startup-id ${lib.getExe pkgs.gregctl} toggle";
"XF86MonBrightnessUp" = "exec --no-startup-id brightnessctl set +5%";
"XF86MonBrightnessDown" = "exec --no-startup-id brightnessctl set 5%-";
"Print" = "exec scrot %Y-%m-%d_$wx$h_scrot.png -z -e 'mv $f /home/daniel/Pictures/screenshots/'";
"${modifier}+Print" = "exec scrot /home/daniel/Pictures/Screenshots/%Y-%m-%d_$wx$h_scrot.png -z";
"${modifier}+l" = "exec ${pkgs.writers.writeBash "hello_world" ''
dunstctl set-paused true
${pkgs.i3lock}/bin/i3lock -n -i ~/images/wallpapers/locked.png
dunstctl set-paused false
''}";
"XF86Display" = "exec arandr";
"${modifier}+Shift+U" = "exec $HOME/.config/nixpkgs/nix-dotfiles/scripts/dmenuunicode";
"${modifier}+Shift+s" = "exec $HOME/.config/nixpkgs/nix-dotfiles/scripts/dmenuaudio";
"${modifier}+Shift+v" = "exec ${pkgs.writers.writeBash "switch_audio" ''
if pw-link -l | grep "^VirtualMic:input_FL" -A 2 | grep FilteredMic; then
${pkgs.pipewire}/bin/pw-link -d "FilteredMic:capture_MONO" "VirtualMic:input_FL"
${pkgs.pipewire}/bin/pw-link -d "FilteredMic:capture_MONO" "VirtualMic:input_FR"
${pkgs.pipewire}/bin/pw-link "VoiceChanger:monitor_FL" "VirtualMic:input_FL"
${pkgs.pipewire}/bin/pw-link "VoiceChanger:monitor_FR" "VirtualMic:input_FR"
${pkgs.pipewire}/bin/pw-link "VoiceChanger:monitor_FL" "VirtualHeadset:playback_FL"
${pkgs.pipewire}/bin/pw-link "VoiceChanger:monitor_FR" "VirtualHeadset:playback_FR"
else
${pkgs.pipewire}/bin/pw-link "FilteredMic:capture_MONO" "VirtualMic:input_FL"
${pkgs.pipewire}/bin/pw-link "FilteredMic:capture_MONO" "VirtualMic:input_FR"
${pkgs.pipewire}/bin/pw-link -d "VoiceChanger:monitor_FL" "VirtualMic:input_FL"
${pkgs.pipewire}/bin/pw-link -d "VoiceChanger:monitor_FR" "VirtualMic:input_FR"
${pkgs.pipewire}/bin/pw-link -d "VoiceChanger:monitor_FL" "VirtualHeadset:playback_FL"
${pkgs.pipewire}/bin/pw-link -d "VoiceChanger:monitor_FR" "VirtualHeadset:playback_FR"
fi
''}";
"${modifier}+d" = "exec ${dmenu}";
"${modifier}+n" = execScope "dolphin";
"${modifier}+b" = execScope "firefox";
"${modifier}+t" = execScope "gedit";
"${modifier}+Return" = execScope "kitty";
"${modifier}+Shift+Return" = execScope "kitty -e ssh dandellion@lilith";
};
startup = [
{
command = "${pkgs.polkit_gnome}/libexec/polkit-gnome-authentication-agent-1";
always = false;
#notification = false;
}
];
window = {
titlebar = false;
hideEdgeBorders = "smart";
};
floating.criteria = [
{ title = "Steam - Update News"; }
];
};
i3.extraConfig = ''
for_window [title="Steam Big Picture Mode"] floating enable, resize set 1920 1080, move position 0 0, border pixel 0
'';
};
};
services.picom = {
enable = true;
backend = "xrender";
};
gtk = {
enable = true;
theme = {
package = pkgs.breeze-gtk;
name = "Breeze";
};
iconTheme = {
package = pkgs.breeze-icons;
name = "breeze";
};
};
# qt = {
# enable = true;
# platformTheme = "gtk";
# };
xsession.windowManager.command = lib.mkIf non-nixos.enable (lib.mkForce "${pkgs.nixgl.auto.nixGLDefault}/bin/nixGL ${config.xsession.windowManager.i3.package}/bin/i3");
home.packages = [
pkgs.brightnessctl
pkgs.xorg.xkill
pkgs.arandr
pkgs.dunst
pkgs.libnotify
pkgs.dmenu
pkgs.scrot
pkgs.neofetch
#pkgs.dan.colors
pkgs.xclip
pkgs.dejavu_fonts
pkgs.source-code-pro
pkgs.breeze-qt5
pkgs.breeze-icons
];
};
}

View File

@@ -0,0 +1,167 @@
{pkgs, config, lib, ...}:
{
config = lib.mkIf config.profiles.xsession.enable {
home.file.dunst = {
target = ".config/dunst/dunstrc";
text = ''
[global]
monitor = 0
follow = keyboard
geometry = "350x5-0+24"
indicate_hidden = yes
shrink = yes
transparency = 20
notification_height = 0
separator_height = 2
padding = 0
horizontal_padding = 8
frame_width = 3
frame_color = "#282828"
# Define a color for the separator.
# possible values are:
# * auto: dunst tries to find a color fitting to the background;
# * foreground: use the same color as the foreground;
# * frame: use the same color as the frame;
# * anything else will be interpreted as a X color.
separator_color = frame
# Sort messages by urgency.
sort = yes
idle_threshold = 120
font = Monospace 11
line_height = 0
markup = full
# The format of the message. Possible variables are:
# %a appname
# %s summary
# %b body
# %i iconname (including its path)
# %I iconname (without its path)
# %p progress value if set ([ 0%] to [100%]) or nothing
# %n progress value if set without any extra characters
# %% Literal %
# Markup is allowed
format = "%s\n%b"
alignment = left
show_age_threshold = 60
word_wrap = yes
ellipsize = middle
ignore_newline = no
stack_duplicates = true
hide_duplicate_count = true
show_indicators = yes
icon_position = left
max_icon_size = 40
#icon_path = /usr/share/icons/gnome/16x16/status/:/usr/share/icons/gnome/16x16/devices/:/usr/share/icons/Adwaita/256x256/status/
sticky_history = yes
history_length = 20
dmenu = ${pkgs.dmenu}/bin/dmenu -p dunst:
browser = ${pkgs.firefox}/bin/firefox -new-tab
# Always run rule-defined scripts, even if the notification is suppressed
always_run_script = true
title = Dunst
class = Dunst
startup_notification = false
force_xinerama = false
[experimental]
per_monitor_dpi = false
[shortcuts]
# Needs to change to alt/super
close = mod1+space
close_all = mod1+shift+space
history = mod1+bar
context = mod1+period
[urgency_low]
# IMPORTANT: colors have to be defined in quotation marks.
# Otherwise the "#" and following would be interpreted as a comment.
background = "#282828"
foreground = "#928374"
timeout = 5
# Icon for notifications with low urgency, uncomment to enable
#icon = /path/to/icon
[urgency_normal]
background = "#458588"
foreground = "#ebdbb2"
timeout = 5
[urgency_critical]
background = "#cc2421"
foreground = "#ebdbb2"
frame_color = "#fabd2f"
timeout = 0
# Every section that isn't one of the above is interpreted as a rules to
# override settings for certain messages.
# Messages can be matched by "appname", "summary", "body", "icon", "category",
# "msg_urgency" and you can override the "timeout", "urgency", "foreground",
# "background", "new_icon" and "format".
# Shell-like globbing will get expanded.
#
# SCRIPTING
# You can specify a script that gets run when the rule matches by
# setting the "script" option.
# The script will be called as follows:
# script appname summary body icon urgency
# where urgency can be "LOW", "NORMAL" or "CRITICAL".
#
# NOTE: if you don't want a notification to be displayed, set the format
# to "".
# NOTE: It might be helpful to run dunst -print in a terminal in order
# to find fitting options for rules.
#[espeak]
# summary = "*"
# script = dunst_espeak.sh
#[script-test]
# summary = "*script*"
# script = dunst_test.sh
#[ignore]
# # This notification will not be displayed
# summary = "foobar"
# format = ""
#[history-ignore]
# # This notification will not be saved in history
# summary = "foobar"
# history_ignore = yes
#[signed_on]
# appname = Pidgin
# summary = "*signed on*"
# urgency = low
#
#[signed_off]
# appname = Pidgin
# summary = *signed off*
# urgency = low
#
#[says]
# appname = Pidgin
# summary = *says*
# urgency = critical
#
#[twitter]
# appname = Pidgin
# summary = *twitter.com*
# urgency = normal
#
# vim: ft=cfg
'';
};
};
}

View File

@@ -0,0 +1,267 @@
{ pkgs, config, lib, ... }:
let
cfg = config.profiles.xsession;
in
{
config = lib.mkIf cfg.enable {
xsession.windowManager.i3.config = {
bars = [];
startup = [
{ command = "systemctl --user restart polybar"; always = true; notification = false; }
];
};
services.polybar = {
enable = true;
package = pkgs.polybar.override {
i3Support = true;
};
script = "polybar bot &";
config = {
"colors" = {
background = "#B2000000";
background-alt = "#444";
foreground = "#dfdfdf";
foreground-alt = "#BBB";
primary = "#ffb52a";
secondary = "#e60053";
alert = "#bd2c40";
};
"bar/bot" = {
bottom = true;
width = "100%";
height = 27;
font-0 = "MesloLGS NF:fontformat=truetype:pixelsize=11;1";
font-1 = "Kozuka Mincho Pro:pixelsize=11;1";
background = "\${colors.background}";
foreground = "\${colors.foreground}";
padding-left = "0";
padding-right = "2";
module-margin-left = "1";
module-margin-right = "2";
modules-left = "i3 title";
modules-right = "countdown minecraft wlan eth filesystem uquota cpu memory battery date";
};
"module/i3" = {
type = "internal/i3";
format = "<label-state> <label-mode>";
scroll-up = "i3wm-wsnext";
scroll-down = "i3wm-wsprev";
label-mode-padding = "0";
label-mode-foreground = "#000";
label-mode-background = "\${colors.primary}";
label-focused = "%index%";
label-focused-background = "\${colors.background-alt}";
label-focused-underline= "\${colors.primary}";
label-focused-padding = "1";
label-unfocused = "%index%";
label-unfocused-padding = "1";
label-visible = "%index%";
label-visible-background = "\${self.label-focused-background}";
label-visible-underline = "\${self.label-focused-underline}";
label-visible-padding = "\${self.label-focused-padding}";
label-urgent = "%index%";
label-urgent-background = "\${colors.alert}";
label-urgent-padding = "1";
};
"module/title" = {
type = "internal/xwindow";
label-maxlen = 40;
};
"module/wlan" = lib.mkIf (config.machine.wlan != null) {
type = "internal/network";
interface = config.machine.wlan;
interval = "3.0";
format-connected = "<ramp-signal> <label-connected>";
format-connected-underline = "#9f78e1";
label-connected = "(%signal%% on %essid%) %local_ip%";
format-disconnected = "";
ramp-signal-0 = "";
ramp-signal-1 = "";
ramp-signal-2 = "";
ramp-signal-3 = "";
ramp-signal-4 = "";
ramp-signal-foreground = "\${colors.foreground-alt}";
};
"module/eth" = lib.mkIf (config.machine.eth != null)
{
type = "internal/network";
interface = "${config.machine.eth}";
interval = "3.0";
format-connected-underline = "#55aa55";
format-connected-prefix = " ";
format-connected-prefix-foreground = "\${colors.foreground-alt}";
label-connected = "%local_ip%";
format-disconnected = "";
};
"module/filesystem" = {
type = "internal/fs";
interval = 25;
mount-0 = "/";
mount-1 = lib.mkIf (config.machine.secondary-fs != null) config.machine.secondary-fs;
label-mounted = "%{F#0a81f5}%mountpoint%%{F-}: %free%";
label-unmounted = "%mountpoint% not mounted";
label-unmounted-foreground = "\${colors.foreground-alt}";
};
"module/cpu" = {
type = "internal/cpu";
interval = 2;
format-prefix = " ";
format-prefix-foreground = "\${colors.foreground-alt}";
format-underline = "#f90000";
label = "%percentage:2%%";
};
"module/memory" = {
type = "internal/memory";
interval = "2";
format-prefix = " ";
format-prefix-foreground = "\${colors.foreground-alt}";
format-underline = "#4bffdc";
label = "%percentage_used%%";
};
"module/battery" = {
type = "internal/battery";
battery = "BAT0";
adapter = "AC";
format-charging = "<animation-charging> <label-charging>";
format-charging-underline = "#ffb52a";
format-discharging = "<animation-discharging> <label-discharging>";
format-discharging-underline = "\${self.format-charging-underline}";
format-full-prefix-foreground = "\${colors.foreground-alt}";
format-full-underline = "\${self.format-charging-underline}";
ramp-capacity-foreground = "\${colors.foreground-alt}";
format-full-prefix = " ";
ramp-capacity-0 = "";
ramp-capacity-1 = "";
ramp-capacity-2 = "";
animation-charging-0 = "";
animation-charging-1 = "";
animation-charging-2 = "";
animation-charging-foreground = "\${colors.foreground-alt}";
animation-charging-framerate = "750";
animation-discharging-0 = "";
animation-discharging-1 = "";
animation-discharging-2 = "";
animation-discharging-foreground = "\${colors.foreground-alt}";
animation-discharging-framerate = "750";
};
"module/date" = {
type = "internal/date";
internal = 5;
date = "%Y-%m-%d";
time = "%H:%M:%S";
label = "%date% %time%";
};
"module/countdown" = {
type = "custom/script";
exec-if = "test -f $HOME/countdown";
exec = "" + pkgs.writers.writeBash "countdown" ''
secs=$(( $(${pkgs.coreutils}/bin/date +%s -d $(${pkgs.coreutils}/bin/cat $HOME/countdown)) - $( ${pkgs.coreutils}/bin/date +%s ) ))
printf '%d:%02d:%02d:%02d\n' $((secs/86400)) $((secs%86400/3600)) $((secs%3600/60)) $((secs%60))
'';
interval = 1;
};
"module/minecraft" = {
type = "custom/script";
exec = "" + pkgs.writers.writePython3 "minecraft_status" {
libraries = with pkgs.python3.pkgs; [ mcstatus notify2 ];
flakeIgnore = [ "E722" ];
} ''
from mcstatus import JavaServer
import signal
from time import sleep
import notify2
pvv = JavaServer.lookup("minecraft.pvv.ntnu.no")
dods = JavaServer.lookup("mc.dodsorf.as")
def getPlayers(server):
try:
status = server.status()
except:
return []
else:
return status.players.sample or []
def build_players(list, server):
result = ""
if len(list) > 0:
result += server + ": "
for player in list:
result += player.name + " "
return result + "\n"
def display_players(pvv, dods):
result = build_players(getPlayers(pvv), "PVV")
result += build_players(getPlayers(dods), "DODS")
return result
def peek(*_):
result = display_players(pvv, dods)
notify2.init('Minecraft Server Status')
n = notify2.Notification("Minecraft Server Status", result)
n.show()
main()
signal.signal(signal.SIGUSR1, peek)
def main():
while True:
result = ""
pvvs = getPlayers(pvv)
dodss = getPlayers(dods)
if len(pvvs) > 0:
result += "P" + str(len(pvvs))
if len(dodss) > 0:
result += "D" + str(len(dodss))
print(result, flush=True)
sleep(5)
main()
'';
click-left = "kill -USR1 %pid%";
# interval =
tail = true;
format = " <label>";
};
};
};
};
}

View File

@@ -0,0 +1,32 @@
{ pkgs, config, lib, ...}:
{
config = lib.mkIf config.profiles.xsession.enable {
home.file.kitty = {
target = ".config/kitty/kitty.conf";
text = ''
#term xterm-256color
font_family MesloLGS NF
font_size 12.0
background_opacity 0.7
clear_all_shortcuts yes
map ctrl+shift+c copy_to_clipboard
map ctrl+shift+v paste_from_clipboard
map ctrl+plus change_font_size all +2.0
map ctrl+shift+plus change_font_size all -2.0
'';
};
home.packages = [
pkgs.kitty
pkgs.ncurses.dev
];
};
}