Add work machine

This commit is contained in:
Erwin Boskma 2022-11-11 11:54:21 +01:00
parent cc55b72b66
commit 2bdd175d38
Signed by: erwin
SSH key fingerprint: SHA256:Vw4O4qA0i5x65Y7yyjDpWDCSMSXAhqT4X7cJ3frdnLY
34 changed files with 1593 additions and 17 deletions

View file

@ -196,6 +196,7 @@
nix-prefetch-scripts
nix-prefetch-github
nix-prefetch-docker
nixos-install-tools
];
};

View file

@ -0,0 +1,309 @@
{ lib
, pkgs
, config
, ...
}:
with lib; let
cfg = config.eboskma.programs.i3;
mod = "Mod4";
i3lockcmd = "i3lock --image ${toString ./wallpapers/jwst-southern-ring-nircam-miri-side-by-side-3840.png} --color=333333ff --tiling --ignore-empty-password --show-failed-attempts --screen=0 --clock --pass-volume-keys";
rofiPower = pkgs.writeShellScriptBin "rofi-power" (builtins.readFile ./powermenu.sh);
left = "n";
down = "e";
up = "i";
right = "o";
workspacePartition =
builtins.partition (n: (trivial.mod n 2) != 0) (lists.range 1 10);
installSessionScript = pkgs.writeShellScriptBin "install-session" ''
sudo ln -fs ${pkgs.i3-gaps}/share/xsessions/i3.desktop /usr/share/xsessions/i3.desktop
sudo ln -fs ${pkgs.i3-gaps}/share/xsessions/i3-with-shmlog.desktop /usr/share/xsessions/i3-with-shmlog.desktop
'';
remoteSessionScript = pkgs.writeShellScriptBin "remote-session" ''
${pkgs.xorg.xrandr}/bin/xrandr --output DP-0 --mode 2560x1440
${pkgs.xorg.xrandr}/bin/xrandr --output DP-4 --mode 2560x1440 --right-of DP-0
${pkgs.nitrogen}/bin/nitrogen --head=0 --set-auto ${toString ./wallpapers/jwst-carina-cosmic-cliffs-nircam-2560.png}
${pkgs.nitrogen}/bin/nitrogen --head=1 --set-auto ${toString ./wallpapers/jwst-southern-ring-nircam-miri-side-by-side-2560.png}
systemctl --user restart polybar
'';
localSessionScript = pkgs.writeShellScriptBin "local-session" ''
${pkgs.xorg.xrandr}/bin/xrandr --output DP-0 --mode 3840x2160
${pkgs.xorg.xrandr}/bin/xrandr --output DP-4 --mode 3840x2160 --right-of DP-0
${pkgs.nitrogen}/bin/nitrogen --head=0 --set-auto ${toString ./wallpapers/jwst-carina-cosmic-cliffs-nircam-3840.png}
${pkgs.nitrogen}/bin/nitrogen --head=1 --set-auto ${toString ./wallpapers/jwst-southern-ring-nircam-miri-side-by-side-3840.png}
systemctl --user restart polybar
'';
menu = "${pkgs.rofi}/bin/rofi -show drun -no-lazy-grab";
in
{
options.eboskma.programs.i3.enable = mkEnableOption "Enable i3";
config = mkIf cfg.enable {
xsession = {
enable = true;
windowManager.i3 = {
enable = true;
package = pkgs.i3-gaps;
config = {
inherit menu;
modifier = mod;
assigns = {
"1" = [{ class = "Firefox"; }];
"2" = [{ class = "Alacritty"; } { class = "foot"; }];
"3" = [{ class = "Code"; }];
"4" = [{ class = "telegramdesktop"; } { class = "Signal"; }];
};
# Dracula theme
colors = {
background = "#f8f8f2";
focused = {
border = "#6272a4";
background = "#6272A4";
text = "#f8f8f2";
indicator = "#6272a4";
childBorder = "#6272a4";
};
focusedInactive = {
border = "#44475a";
background = "#44475a";
text = "#f8f8f2";
indicator = "#44475a";
childBorder = "#44475a";
};
unfocused = {
border = "#282a36";
background = "#282a36";
text = "#bfbfbf";
indicator = "#282a36";
childBorder = "#282a36";
};
urgent = {
border = "#44475a";
background = "#ff5555";
text = "#f8f8f2";
indicator = "#ff5555";
childBorder = "#ff5555";
};
placeholder = {
border = "#282a36";
background = "#282a36";
text = "#f8f8f2";
indicator = "#282a36";
childBorder = "#282a36";
};
};
floating = {
criteria = [{ instance = "gnome-calculator"; } { class = "Pavucontrol"; }];
modifier = mod;
};
fonts = {
names = [ "Iosevka Nerd Font" ];
style = "Regular";
size = 12.0;
};
gaps = {
inner = 10;
outer = 5;
smartBorders = "on";
};
keybindings = {
"${mod}+Return" = "exec --no-startup-id ${config.xsession.windowManager.i3.config.terminal}";
"${mod}+Shift+q" = "kill";
"${mod}+s" = "exec --no-startup-id ${config.xsession.windowManager.i3.config.menu}";
"${mod}+Shift+s" = "exec --no-startup-id ${pkgs.rofi}/bin/rofi -no-lazy-grab -show run";
"${mod}+${left}" = "focus left";
"${mod}+${down}" = "focus down";
"${mod}+${up}" = "focus up";
"${mod}+${right}" = "focus right";
"${mod}+Left" = "focus left";
"${mod}+Down" = "focus down";
"${mod}+Up" = "focus up";
"${mod}+Right" = "focus right";
"${mod}+Shift+${left}" = "move left";
"${mod}+Shift+${down}" = "move down";
"${mod}+Shift+${up}" = "move up";
"${mod}+Shift+${right}" = "move right";
"${mod}+Shift+Left" = "move left";
"${mod}+Shift+Down" = "move down";
"${mod}+Shift+Up" = "move up";
"${mod}+Shift+Right" = "move right";
"${mod}+h" = "split h";
"${mod}+v" = "split v";
"${mod}+t" = "fullscreen toggle";
"${mod}+a" = "focus parent";
"${mod}+r" = "layout stacking";
"${mod}+w" = "layout tabbed";
"${mod}+f" = "layout toggle split";
"${mod}+Shift+space" = "floating toggle";
"${mod}+space" = "focus mode_toggle";
"${mod}+1" = "workspace number 1";
"${mod}+2" = "workspace number 2";
"${mod}+3" = "workspace number 3";
"${mod}+4" = "workspace number 4";
"${mod}+5" = "workspace number 5";
"${mod}+6" = "workspace number 6";
"${mod}+7" = "workspace number 7";
"${mod}+8" = "workspace number 8";
"${mod}+9" = "workspace number 9";
"${mod}+0" = "workspace number 10";
"${mod}+Shift+1" = "move container to workspace number 1";
"${mod}+Shift+2" = "move container to workspace number 2";
"${mod}+Shift+3" = "move container to workspace number 3";
"${mod}+Shift+4" = "move container to workspace number 4";
"${mod}+Shift+5" = "move container to workspace number 5";
"${mod}+Shift+6" = "move container to workspace number 6";
"${mod}+Shift+7" = "move container to workspace number 7";
"${mod}+Shift+8" = "move container to workspace number 8";
"${mod}+Shift+9" = "move container to workspace number 9";
"${mod}+Shift+0" = "move container to workspace number 10";
"${mod}+Shift+minus" = "move scratchpad";
"${mod}+minus" = "scratchpad show";
"${mod}+Shift+c" = "reload";
"${mod}+Shift+p" = "restart";
"${mod}+Shift+f" = "exec --no-startup-id ${rofiPower}/bin/rofi-power";
"${mod}+l" = "exec --no-startup-id ${i3lockcmd}";
"${mod}+p" = "mode resize";
"${mod}+Pause" = "mode passthrough";
"${mod}+c" = "exec --no-startup-id emacsclient -c";
"${mod}+Print" = "exec --no-startup-id ${pkgs.maim}/bin/maim --window $(${pkgs.xdotool}/bin/xdotool getactivewindow) ~/$(${pkgs.coreutils}/bin/date '+%Y-%m-%d-%T)-screenshot.png";
"${mod}+Shift+Print" = "exec --no-startup-id ${pkgs.maim}/bin/maim --window $(${pkgs.xdotool}/bin/xdotool getactivewindow) | ${pkgs.xclip}/bin/xclip -selection clipboard -t image/png";
"${mod}+Shift+Ctrl+Print" = "exec --no-startup-id ${pkgs.maim}/bin/maim -s | ${pkgs.xclip}/bin/xclip -selection clipboard -t image/png";
"XF86AudioRaiseVolume" = "exec --no-startup-id ${pkgs.pamedia}/bin/pamedia up";
"XF86AudioLowerVolume" = "exec --no-startup-id ${pkgs.pamedia}/bin/pamedia down";
"XF86AudioMute" = "exec --no-startup-id ${pkgs.pamedia}/bin/pamedia mute";
"XF86Calculator" = "exec ${pkgs.gnome.gnome-calculator}/bin/gnome-calculator";
};
modes = {
passthrough = {
"${mod}+Pause" = "mode default";
};
};
# terminal = "${pkgs.alacritty}/bin/alacritty";
terminal = "/usr/bin/alacritty";
window = {
border = 1;
titlebar = false;
};
bars = [ ];
workspaceAutoBackAndForth = true;
workspaceOutputAssign = builtins.concatLists (builtins.attrValues (builtins.mapAttrs
(
name: workspaces:
let
output =
if name == "right"
then "DP-0"
else "DP-4";
in
builtins.map
(ws: {
inherit output;
workspace = toString ws;
})
workspaces
)
workspacePartition));
# [
# { output = "DP-0"; workspace = "1"; }
# ];
startup = [
{
command = "/usr/lib/policykit-1-gnome/polkit-gnome-authentication-agent-1";
notification = false;
}
# {
# command = "/home/erwin/.config/polybar/launch.sh --shades";
# notification = false;
# always = true;
# }
{
command = "${pkgs.networkmanagerapplet}/bin/nm-applet";
notification = false;
}
{
command = ''${pkgs.xorg.xinput}/bin/xinput set-int-prop "Logitech USB Laser Mouse" "libinput Natural Scrolling Enabled" 8 1'';
notification = false;
always = true;
}
{
command = ''${pkgs.xorg.xinput}/bin/xinput set-float-prop "Logitech USB Laser Mouse" "libinput Accel Speed" 1'';
notification = false;
always = true;
}
{
command = "${pkgs.xorg.xrandr}/bin/xrandr --output DP-0 --primary --left-of DP-4";
notification = false;
}
# {
# command = "${pkgs.nitrogen}/bin/nitrogen --restore";
# notification = false;
# }
# {
# command = "${pkgs.tdesktop}/bin/telegram-desktop";
# notification = false;
# }
{
command = "${pkgs.xorg.xset}/bin/xset +dpms dpms 900 1200 1500";
notification = false;
}
{
command = "${pkgs.dropbox}/bin/dropbox start";
notification = false;
}
];
};
extraConfig = ''
'';
};
};
eboskma.wallpapers = {
enable = true;
images = [
./wallpapers/river-3840.png
./wallpapers/jwst-pillars-of-creation-3840.jpg
];
};
home = {
file.".wallpapers".source = ./wallpapers;
packages = with pkgs; [
dunst
installSessionScript
localSessionScript
remoteSessionScript
];
};
};
}

View file

@ -0,0 +1,54 @@
#!/bin/bash
confirm() {
rofi -dmenu \
-i \
-no-fixed-num-lines \
-p "Are you sure? [y/n]: " \
-theme power
}
# Options
shutdown=""
reboot=""
lock=""
hibernate=""
exit_wm=""
# Variable passed to rofi
options="${shutdown}\n${reboot}\n${lock}\n${hibernate}\n${exit_wm}"
uptime=$(uptime | awk '{print $1}' || true)
lockcmd="i3lock --ignore-empty-password --show-failed-attempts --clock --color=333333ff --screen=0 --pass-volume-keys --image /home/erwin/.wallpapers/river-3840.png --tiling"
chosen="$(echo -e "${options}" | rofi -theme power -p "Uptime: ${uptime}" -dmenu -selected-row 2)"
if [[ "${chosen}" == "" ]]; then
exit 0
fi
if [[ "${chosen}" == "${lock}" ]]; then
${lockcmd}
exit 0
fi
answer=$(confirm)
if [[ "${answer}" == "y" ]]; then
case "${chosen}" in
"${shutdown}")
systemctl poweroff
;;
"${reboot}")
systemctl reboot
;;
"${hibernate}")
${lockcmd}
systemctl hibernate
;;
"${exit_wm}")
i3-msg exit
;;
*) ;;
esac
fi

Binary file not shown.

After

Width:  |  Height:  |  Size: 580 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.3 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.7 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.4 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.8 MiB

View file

@ -0,0 +1,25 @@
{ pkgs
, config
, lib
, ...
}:
with lib; let
cfg = config.eboskma.programs.mpd;
in
{
options.eboskma.programs.mpd = { enable = mkEnableOption "mpd"; };
config = mkIf (cfg.enable) {
services.mpd = {
enable = true;
network = {
startWhenNeeded = true;
};
};
services.mpdris2 = {
enable = true;
notifications = true;
};
};
}

View file

@ -0,0 +1,72 @@
{ pkgs
, config
, lib
, inputs
, ...
}:
with lib; let
cfg = config.eboskma.programs.picom;
picom = pkgs.writeShellScriptBin "picom" ''
${pkgs.nixgl.auto.nixGLDefault}/bin/nixGL ${pkgs.picom}/bin/picom $@
'';
in
{
options.eboskma.programs.picom = { enable = mkEnableOption "activate picom"; };
config = mkIf (cfg.enable) {
# home.packages = [pkgs.nixgl.auto.nixGLDefault];
services.picom = {
enable = true;
package = picom;
backend = "glx";
vSync = true;
experimentalBackends = true;
fade = true;
fadeSteps = [ 0.08 0.08 ];
shadow = true;
inactiveOpacity = 0.8;
opacityRules = [
"0:_NET_WM_STATE@[*]:32a = '_NET_WM_STATE_HIDDEN'"
"100:fullscreen"
"100:name = 'Zoom Meeting'"
"100:name = 'zoom_linux_float_video_window'"
"100:class_g = 'Rofi'"
"100:class_g = 'mpv'"
"100:window_type = 'combo'"
"100:window_type = 'dock'"
"100:window_type = 'dropdown_menu'"
"100:window_type = 'menu'"
"100:window_type = 'popup_menu'"
"100:window_type = 'splash'"
"100:window_type = 'tooltip'"
"100:window_type = 'utility'"
"90:!focused"
];
settings = {
unredir-if-possible = false;
mark-ovredir-focused = true;
use-ewmh-active-win = true;
blur = {
method = "gaussian";
size = 10;
deviation = 5.0;
};
inactive-dim = 0.2;
wintypes = {
dock = { shadow = false; };
dnd = { shadow = false; };
popup_menu = { shadow = false; opacity = 1.0; };
dropdown_menu = { shadow = false; opacity = 1.0; };
};
};
};
};
}

View file

@ -0,0 +1,345 @@
{ pkgs
, config
, lib
, ...
}:
with lib; let
cfg = config.eboskma.programs.polybar;
colors = {
background = "#cc000000";
foreground = "#ffffffff";
urgent = "#c9545d";
};
polybar-playerctl =
let
pythonWithPackages = pkgs.python3.withPackages (pythonPackages: [
pythonPackages.pygobject3
]);
in
pkgs.stdenv.mkDerivation {
name = "polybar-playerctl";
buildInputs = [
pythonWithPackages
pkgs.playerctl
];
propagatedBuildInputs = [
pythonWithPackages
pkgs.python3Packages.pygobject3
pkgs.playerctl
];
nativeBuildInputs = [
pkgs.gobject-introspection
pkgs.wrapGAppsHook
];
strictDeps = false;
dontUnpack = true;
installPhase = ''
mkdir -p $out/bin
cp ${./scripts/polybar-playerctl} $out/bin/polybar-playerctl
chmod +x $out/bin/polybar-playerctl
'';
};
headset-battery = pkgs.writeShellScript "headset-battery" ''
battery_level=$(${pkgs.headsetcontrol}/bin/headsetcontrol -c -b)
battery_icons=( )
battery_charging=""
if [ "''${battery_level}" -eq -1 ]; then
printf "%s " "''${battery_charging}"
else
idx=$(((battery_level / 10)))
if [ "''${idx}" -eq 10 ]; then
idx=9
fi
battery_icon="''${battery_icons[''${idx}]}"
printf "%s %i%%" "''${battery_icon}" "''${battery_level}"
fi
'';
in
{
options.eboskma.programs.polybar = { enable = mkEnableOption "activate polybar"; };
config = mkIf (cfg.enable) {
# systemd.user.services.polybar = {
# Install = { WantedBy = [ "graphical-session.target" ]; };
# };
services.polybar = {
enable = true;
package = pkgs.polybarFull.override {
i3GapsSupport = true;
};
script = ''
${pkgs.polybar}/bin/polybar-msg cmd quit
while ${pkgs.procps}/bin/pgrep -u ''${UID} -x polybar > /dev/null; do sleep 0.1; done
outputs=$(${pkgs.polybar}/bin/polybar -m | ${pkgs.coreutils}/bin/cut -d ':' -f 1)
primary=$(${pkgs.polybar}/bin/polybar -m | ${pkgs.gnugrep}/bin/grep primary | ${pkgs.coreutils}/bin/cut -d ':' -f 1)
for m in ''${outputs}; do
MONITOR=''${m} polybar -q main & disown
done
'';
settings = {
"global/wm" = {
margin.bottom = 0;
margin.top = 0;
};
"bar/main" = {
monitor = ''''${env:MONITOR:DP-0}'';
fixed.center = true;
width = "100%";
height = 48;
# offset.x = "1%";
# offset.y = "2%";
offset.x = 0;
offset.y = 0;
background = "${colors.background}";
foreground = "${colors.foreground}";
line.size = 2;
font = [
"Monofur Nerd Font:style=Bold:size=16;2"
"Monofur Nerd Font:size=18;3"
"Monofur Nerd Font:size=20;4"
];
modules = {
left = "launcher workspaces playerctl";
center = "date";
right = "headset-battery memory cpu pulseaudio network";
};
dim.value = 0.8;
tray = {
position = "right";
detached = false;
maxsize = 24;
background = "${colors.background}";
offset.x = 0;
offset.y = 0;
padding = 0;
scale = 1.0;
};
enable.ipc = true;
cursor = {
click = "pointer";
};
};
settings = {
screenchange.reload = false;
throttle.output.text = 5;
throttle.output.for = 10;
compositing = {
background = "source";
foreground = "over";
overline = "over";
underline = "over";
border = "over";
};
pseudo.transparency = false;
};
"module/launcher" = {
type = "custom/text";
content.text = "";
content.padding = 2;
click.left = "${pkgs.rofi}/bin/rofi -show drun -no-lazy-grab";
};
"module/workspaces" = {
# type = "internal/xworkspaces";
# pin.workspaces = true;
# enable.click = true;
# enable.scroll = true;
# icon.text = [ "1;" "2;" "3;" "4;" "5;" ];
# icon.default = "";
# format.text = "<label-state>";
# format.padding = 1;
# label.active.text = "";
# label.occupied.text = "";
# label.empty.text = "";
# label.urgent.text = "";
# label.urgent.background = "${colors.urgent}";
# label.active.padding = 1;
# label.urgent.padding = 1;
# label.occupied.padding = 1;
# label.empty.padding = 1;
type = "internal/i3";
pin.workspaces = true;
strip.wsnumbers = true;
enable.click = true;
enable.scroll = true;
# ws.icon.text = [ "1;" "2;" "3;" "4;" "5;" "6;" "7;" "8;" "9;" "10;" ];
# ws.icon.text = [ "1" "2" "3" "4" "5" "6" "7" "8" "9" "10" ];
# ws.icon.default = "";
format = "<label-state> <label-mode>";
label.mode.text = "%mode%";
label.mode.padding = 1;
# label.focused.text = "";
label.focused.text = "%index%";
label.focused.padding = 1;
label.focused.background = "#333333";
label.focused.underline = "#ffffff";
# label.unfocused.text = "";
label.unfocused.text = "%index%";
label.unfocused.padding = 1;
# label.visible.text = "";
label.visible.text = "%index%";
label.visible.padding = 1;
# label.urgent.text = "";
label.urgent.text = "%index%";
label.urgent.background = "${colors.urgent}";
label.urgent.padding = 1;
};
"module/playerctl" = {
type = "custom/script";
exec = "${polybar-playerctl}/bin/polybar-playerctl";
interval = 1;
click.left = "${polybar-playerctl}/bin/polybar-playerctl play-pause";
click.middle = "${polybar-playerctl}/bin/polybar-playerctl next";
click.right = "${polybar-playerctl}/bin/polybar-playerctl prevous";
format.padding = 2;
scroll.up = "${polybar-playerctl}/bin/polybar-playerctl next-player";
};
"module/date" = {
type = "internal/date";
interval = 1.0;
time.text = " %H:%M:%S";
time.alt = " %a, %d %b %Y";
format.text = "<label>";
format.padding = 2;
label.text = "%time%";
};
"module/headset-battery" = {
type = "custom/script";
exec = "${headset-battery}";
interval = 5;
format.prefix = " ";
format.padding = 2;
label.text = "%output%";
click.left = "${pkgs.headsetcontrol}/bin/headsetcontrol -s 128";
click.right = "${pkgs.headsetcontrol}/bin/headsetcontrol -s 0";
};
"module/memory" = {
type = "internal/memory";
interval = 1;
format.text = "<label>";
format.prefix = " ";
format.padding = 2;
label.text = "%mb_used% (%percentage_used%%)";
};
"module/cpu" = {
type = "internal/cpu";
interval = 1;
format.text = "<label>";
format.prefix = "";
format.padding = 2;
label = "%percentage:3%%";
};
"module/pulseaudio" = {
type = "internal/pulseaudio";
interval = 5;
use.ui.max = false;
format.volume.text = "<ramp-volume> <label-volume>";
format.volume.padding = 2;
format.muted.text = "<label-muted>";
format.muted.prefix = "";
format.muted.background = "${colors.urgent}";
format.muted.padding = 2;
label.volume.text = "%percentage%%";
label.muted.text = " Muted";
ramp.volume = [ "" "奔" "" ];
click.right = "${pkgs.pavucontrol}/bin/pavucontrol";
};
"module/network" = {
type = "internal/network";
interval = 1;
interface = "enp4s0";
click-left = "${pkgs.networkmanagerapplet}/bin/nm-connection-editor";
accumulate.stats = true;
unknown.as.up = true;
format.connected.text = "<label-connected>";
format.connected.padding = 2;
format.disconnected.text = "<label-disconnected>";
format.disconnected.padding = 2;
format.packetloss.text = "<animation-packetloss> <label-connected>";
label.connected.text = " %local_ip% %upspeed:9% %downspeed:9%";
label.disconnected.text = "%{A1:networkmanager_dmenu &:} Offline%{A}";
animation.packetloss.text = [
{
text = "";
foreground = "${colors.urgent}";
}
{
text = "";
foreground = "${colors.foreground}";
}
];
animation.packetloss.framerate = 500;
};
};
};
};
}

View file

@ -0,0 +1,84 @@
#!/usr/bin/env python3
import os
import sys
import gi
from gi.repository import GLib
# Check Playerctl version
gi.require_version('Playerctl', '2.0')
from gi.repository import Playerctl
def player_status_str(status):
if status == Playerctl.PlaybackStatus.PLAYING:
return 'Playing'
elif status == Playerctl.PlaybackStatus.PAUSED:
return 'Paused'
elif status == Playerctl.PlaybackStatus.STOPPED:
return 'Stopped'
else:
return 'Unknown'
def now_playing_str(artist, title):
if artist == None and title == None:
return 'No music information'
elif artist == None:
return title
else:
return f'{artist} - {title}'
players = Playerctl.list_players()
if len(players) == 0:
print("No players found")
exit(0)
homedir = os.environ['HOME']
player_file = f'{homedir}/.playerctl_player'
current_player_name = ''
if os.path.isfile(player_file):
with open(player_file, mode='r') as file:
current_player_name = file.read()
player_found = False
player_changed = False
player_index = 0
for (index, p) in enumerate(players):
if p.instance == current_player_name:
player_found = True
player_index = index
break
if not player_found:
player = Playerctl.Player.new_from_name(players[0])
else:
player = Playerctl.Player.new_from_name(players[player_index])
if len(sys.argv) == 1:
out = f'ﱘ [{player.get_property("player-name")}] '
if player.props.playback_status == Playerctl.PlaybackStatus.PLAYING:
out += now_playing_str(player.get_artist(), player.get_title())
else:
out += player_status_str(player.get_property('playback_status'))
print(out)
elif sys.argv[1] == 'next-player':
player_changed = True
player_index += 1
if player_index == len(players):
player_index = 0
player = Playerctl.Player.new_from_name(players[player_index])
elif sys.argv[1] == 'play-pause':
player.play_pause()
elif sys.argv[1] == 'next':
player.next()
elif sys.argv[1] == 'previous':
player.previous()
if player_changed or not player_found:
with open(player_file, mode='w') as file:
file.write(player.get_property('player-instance'))
file.flush()

View file

@ -7,7 +7,14 @@ with lib; let
cfg = config.eboskma.programs.rofi;
in
{
options.eboskma.programs.rofi.enable = mkEnableOption "Enable rofi";
options.eboskma.programs.rofi = {
enable = mkEnableOption "Enable rofi";
package = mkOption {
description = "The rofi package to use";
type = types.package;
default = pkgs.rofi;
};
};
config = mkIf cfg.enable {
programs.rofi = {

View file

@ -0,0 +1,45 @@
{ pkgs, config, lib, ... }:
with lib;
let
cfg = config.eboskma.wallpapers;
i3SetWallpaper = pkgs.writeShellScript "i3-set-wallpaper" (if builtins.isPath cfg.images then
''${pkgs.nitrogen}/bin/nitrogen --set-color=${cfg.backgroundColor} --set-tiled ${cfg.images}''
else
builtins.concatStringsSep "\n" (map
({ fst, snd }:
let
image = fst;
monitor = toString snd;
in
''${pkgs.nitrogen}/bin/nitrogen --head=${monitor} --set-color=${cfg.backgroundColor} --set-tiled ${image}'')
(zipLists cfg.images (builtins.genList (x: x) (builtins.length cfg.images)))));
in
{
options.eboskma.wallpapers = {
enable = mkEnableOption "wallpapers";
backgroundColor = mkOption {
description = "Hex value of the background color";
type = (types.strMatching "#[[:xdigit:]]{6}");
default = "#000000";
example = "#ff0000";
};
images = mkOption {
description = "Image(s) to use as wallpapers. For multiple monitors, either set a single image to use on all monitors, or set a list with as many images as monitors you have";
type = with types; oneOf [ path (nonEmptyListOf path) ];
};
};
config = mkIf cfg.enable {
home.packages = [ pkgs.nitrogen ];
xsession.windowManager.i3.config.startup = [
{
command = toString i3SetWallpaper;
notification = false;
}
];
};
}

View file

@ -0,0 +1,37 @@
{ pkgs, config, lib, ... }:
with lib;
let
cfg = config.eboskma.services.xbanish;
in
{
options.eboskma.services.xbanish = {
enable = mkEnableOption "xbanish";
arguments = mkOption {
description = "Arguments to pass to xbanish command";
default = "";
example = "-d -i shift";
type = types.str;
};
};
config = mkIf (cfg.enable) {
systemd.user.services.xbanish = {
Unit = {
Description = "xbanish hides the mouse pointer when typing";
PartOf = [ "graphical-session.target" ];
};
Service = {
ExecStart = ''
${pkgs.xbanish}/bin/xbanish ${cfg.arguments}
'';
Restart = "always";
};
Install = {
WantedBy = [ "graphical-session.target" ];
};
};
};
}

View file

@ -19,7 +19,7 @@ in
users = {
erwin = {
enable = true;
desktop = true;
home = true;
};
builder.enable = true;
};
@ -39,6 +39,7 @@ in
bluetooth.enable = true;
desktop = {
enable = true;
wayland = true;
home-manager = true;
};
docker.enable = true;

View file

@ -0,0 +1,107 @@
# Edit this configuration file to define what should be installed on
# your system. Help is available in the configuration.nix(5) man page
# and in the NixOS manual (accessible by running nixos-help).
{ config, pkgs, nixos-hardware, ... }:
{
imports =
[
# Include the results of the hardware scan.
nixos-hardware.nixosModules.common-cpu-amd
nixos-hardware.nixosModules.common-cpu-amd-pstate
nixos-hardware.nixosModules.common-gpu-nvidia
nixos-hardware.nixosModules.common-pc-ssd
./hardware-configuration.nix
../../users/erwin
../../users/root
];
eboskma = {
users = {
erwin = {
enable = true;
work = true;
};
};
base = {
plymouth.enable = true;
work = true;
kernel = pkgs.linuxKernel.packages.linux_6_0;
};
desktop = {
enable = true;
home-manager = true;
};
docker.enable = true;
fonts.enable = true;
gnome.enable = true;
greetd.enable = true;
networking.enable = true;
nix-common.enable = true;
sound.enable = true;
systemd.enable = true;
};
# Use the systemd-boot EFI boot loader.
boot.loader = {
systemd-boot = {
enable = true;
configurationLimit = 15;
};
efi.canTouchEfiVariables = true;
};
time.timeZone = "Europe/Amsterdam";
networking = {
hostName = "mimir";
useDHCP = false;
networkManager.enable = true;
useNetworkd = true;
firewall = {
trustedInterfaces = [ "lo" ];
allowedTCPPorts = [
# Horus System V2
12345
5555
5556
];
};
};
systemd.network = {
enable = true;
networks = {
"40-enp4s0" = {
DHCP = "yes";
};
};
};
services.openssh.enable = true;
programs.ssh.startAgent = true;
# sops = {
# defaultSopsFile = ./secrets.yaml;
# secrets = {};
# };
# This value determines the NixOS release from which the default
# settings for stateful data, like file locations and database versions
# on your system were taken. Its perfectly fine and recommended to leave
# this value at the release version of the first install of this system.
# Before changing this value read the documentation for this option
# (e.g. man configuration.nix or on https://nixos.org/nixos/options.html).
system.stateVersion = "22.11"; # Did you read the comment?
}

View file

@ -0,0 +1,284 @@
# Do not modify this file! It was generated by nixos-generate-config
# and may be overwritten by future invocations. Please make changes
# to /etc/nixos/configuration.nix instead.
{ config, lib, pkgs, modulesPath, ... }:
{
imports =
[
(modulesPath + "/installer/scan/not-detected.nix")
];
boot.initrd.availableKernelModules = [ "nvme" "xhci_pci" "ahci" "usb_storage" "usbhid" ];
boot.initrd.kernelModules = [ "dm-snapshot" ];
boot.kernelModules = [ "kvm-amd" ];
boot.extraModulePackages = [ ];
fileSystems."/" =
{
device = "/dev/disk/by-uuid/a07b9942-e77a-4ba7-b766-ad9d94d6bfb7";
fsType = "ext4";
};
fileSystems."/boot/efi" =
{
device = "/dev/disk/by-uuid/5200-060F";
fsType = "vfat";
};
fileSystems."/recovery" =
{
device = "/dev/disk/by-uuid/5200-3497";
fsType = "vfat";
};
fileSystems."/snap/kde-frameworks-5-core18/32" =
{
device = "/var/lib/snapd/snaps/kde-frameworks-5-core18_32.snap";
fsType = "squashfs";
options = [ "loop" ];
};
fileSystems."/snap/lxd/17629" =
{
device = "/var/lib/snapd/snaps/lxd_17629.snap";
fsType = "squashfs";
options = [ "loop" ];
};
fileSystems."/snap/gnome-3-28-1804/145" =
{
device = "/var/lib/snapd/snaps/gnome-3-28-1804_145.snap";
fsType = "squashfs";
options = [ "loop" ];
};
fileSystems."/backup" =
{
device = "/dev/disk/by-uuid/87a9da5a-3eb4-4e2b-8bb0-de1c0e660048";
fsType = "btrfs";
};
fileSystems."/yocto" =
{
device = "/dev/disk/by-uuid/5ce7439d-7ff9-4bb1-ab63-d69feb899cfe";
fsType = "ext4";
};
fileSystems."/home" =
{
device = "/dev/disk/by-uuid/ff039faf-f7d7-4c5b-b6dc-50482b9af677";
fsType = "ext4";
};
fileSystems."/snap/bare/5" =
{
device = "/var/lib/snapd/snaps/bare_5.snap";
fsType = "squashfs";
options = [ "loop" ];
};
fileSystems."/snap/core/13741" =
{
device = "/var/lib/snapd/snaps/core_13741.snap";
fsType = "squashfs";
options = [ "loop" ];
};
fileSystems."/snap/core/13886" =
{
device = "/var/lib/snapd/snaps/core_13886.snap";
fsType = "squashfs";
options = [ "loop" ];
};
fileSystems."/snap/core18/2566" =
{
device = "/var/lib/snapd/snaps/core18_2566.snap";
fsType = "squashfs";
options = [ "loop" ];
};
fileSystems."/snap/core18/2620" =
{
device = "/var/lib/snapd/snaps/core18_2620.snap";
fsType = "squashfs";
options = [ "loop" ];
};
fileSystems."/snap/core20/1634" =
{
device = "/var/lib/snapd/snaps/core20_1634.snap";
fsType = "squashfs";
options = [ "loop" ];
};
fileSystems."/snap/core20/1695" =
{
device = "/var/lib/snapd/snaps/core20_1695.snap";
fsType = "squashfs";
options = [ "loop" ];
};
fileSystems."/snap/core22/310" =
{
device = "/var/lib/snapd/snaps/core22_310.snap";
fsType = "squashfs";
options = [ "loop" ];
};
fileSystems."/snap/doctl/1096" =
{
device = "/var/lib/snapd/snaps/doctl_1096.snap";
fsType = "squashfs";
options = [ "loop" ];
};
fileSystems."/snap/doctl/1122" =
{
device = "/var/lib/snapd/snaps/doctl_1122.snap";
fsType = "squashfs";
options = [ "loop" ];
};
fileSystems."/snap/gnome-3-28-1804/161" =
{
device = "/var/lib/snapd/snaps/gnome-3-28-1804_161.snap";
fsType = "squashfs";
options = [ "loop" ];
};
fileSystems."/snap/gnome-3-34-1804/72" =
{
device = "/var/lib/snapd/snaps/gnome-3-34-1804_72.snap";
fsType = "squashfs";
options = [ "loop" ];
};
fileSystems."/snap/gnome-3-34-1804/77" =
{
device = "/var/lib/snapd/snaps/gnome-3-34-1804_77.snap";
fsType = "squashfs";
options = [ "loop" ];
};
fileSystems."/snap/go/9952" =
{
device = "/var/lib/snapd/snaps/go_9952.snap";
fsType = "squashfs";
options = [ "loop" ];
};
fileSystems."/snap/go/9981" =
{
device = "/var/lib/snapd/snaps/go_9981.snap";
fsType = "squashfs";
options = [ "loop" ];
};
fileSystems."/snap/gtk-common-themes/1534" =
{
device = "/var/lib/snapd/snaps/gtk-common-themes_1534.snap";
fsType = "squashfs";
options = [ "loop" ];
};
fileSystems."/snap/gtk-common-themes/1535" =
{
device = "/var/lib/snapd/snaps/gtk-common-themes_1535.snap";
fsType = "squashfs";
options = [ "loop" ];
};
fileSystems."/snap/lxi-tools/1563" =
{
device = "/var/lib/snapd/snaps/lxi-tools_1563.snap";
fsType = "squashfs";
options = [ "loop" ];
};
fileSystems."/snap/lxi-tools/1577" =
{
device = "/var/lib/snapd/snaps/lxi-tools_1577.snap";
fsType = "squashfs";
options = [ "loop" ];
};
fileSystems."/snap/snapcraft/8513" =
{
device = "/var/lib/snapd/snaps/snapcraft_8513.snap";
fsType = "squashfs";
options = [ "loop" ];
};
fileSystems."/snap/snapcraft/8528" =
{
device = "/var/lib/snapd/snaps/snapcraft_8528.snap";
fsType = "squashfs";
options = [ "loop" ];
};
fileSystems."/snap/snapd/17029" =
{
device = "/var/lib/snapd/snaps/snapd_17029.snap";
fsType = "squashfs";
options = [ "loop" ];
};
fileSystems."/snap/snapd/17336" =
{
device = "/var/lib/snapd/snaps/snapd_17336.snap";
fsType = "squashfs";
options = [ "loop" ];
};
fileSystems."/snap/yq/1805" =
{
device = "/var/lib/snapd/snaps/yq_1805.snap";
fsType = "squashfs";
options = [ "loop" ];
};
fileSystems."/snap/yq/1920" =
{
device = "/var/lib/snapd/snaps/yq_1920.snap";
fsType = "squashfs";
options = [ "loop" ];
};
fileSystems."/var/lib/docker/overlay2/4e29ec585458a234ac12358c1f1916710e9280d18f3055db6f9a872e3f3ceacc/merged" =
{
device = "overlay";
fsType = "overlay";
};
fileSystems."/var/lib/docker/overlay2/1f0b089d78d0820ce1858129b6af0b957d8e63d7a10664d6c469cc092cb8465c/merged" =
{
device = "overlay";
fsType = "overlay";
};
swapDevices =
[{ device = "/dev/disk/by-uuid/82969dda-8804-4314-b916-2d4b5db904d5"; }];
# Enables DHCP on each ethernet and wireless interface. In case of scripted networking
# (the default) this is the recommended approach. When using systemd-networkd it's
# still possible to use this option, but it's recommended to use it in conjunction
# with explicit per-interface declarations with `networking.interfaces.<interface>.useDHCP`.
networking.useDHCP = lib.mkDefault true;
# networking.interfaces.br-0d184fb18be7.useDHCP = lib.mkDefault true;
# networking.interfaces.br-ce69977bdefc.useDHCP = lib.mkDefault true;
# networking.interfaces.docker0.useDHCP = lib.mkDefault true;
# networking.interfaces.enp4s0.useDHCP = lib.mkDefault true;
# networking.interfaces.enp5s0f1.useDHCP = lib.mkDefault true;
# networking.interfaces.veth8f1e18a.useDHCP = lib.mkDefault true;
# networking.interfaces.vethbb81f0b.useDHCP = lib.mkDefault true;
# networking.interfaces.virbr0.useDHCP = lib.mkDefault true;
# networking.interfaces.wg0.useDHCP = lib.mkDefault true;
nixpkgs.hostPlatform = lib.mkDefault warning: the group 'nixbld' specified in 'build-users-group' does not exist;
powerManagement.cpuFreqGovernor = lib.mkDefault "ondemand";
hardware.cpu.amd.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
# high-resolution display
hardware.video.hidpi.enable = lib.mkDefault true;
}

View file

@ -11,12 +11,15 @@ in
{
options.eboskma.desktop = {
enable = mkEnableOption "Enable default desktop configuration";
home-manager = mkOption {
wayland = mkOption {
description = "Configure for wayland";
type = types.bool;
default = false;
};
home-manager = mkOption {
description = "Enable home-manager for this desktop";
type = types.bool;
default = false;
description = ''
Enable home-manager for this desktop
'';
};
};
@ -28,7 +31,7 @@ in
seahorse.enable = true;
sway = {
sway = mkIf cfg.wayland {
enable = true;
wrapperFeatures = {
gtk = true;
@ -41,7 +44,7 @@ in
];
};
hyprland = {
hyprland = mkIf cfg.wayland {
enable = true;
# Required when also using the Home Manager module
@ -58,7 +61,7 @@ in
autostart.enable = true;
portal = {
enable = true;
wlr.enable = true;
wlr.enable = cfg.wayland;
extraPortals = with pkgs; [ xdg-desktop-portal-gtk ];
};
};

View file

@ -19,7 +19,7 @@ in
dates = "weekly";
};
};
virtualisation.oci-containers.containers = {
drone = {
autoStart = true;

View file

@ -17,7 +17,7 @@ in
dates = "weekly";
};
};
virtualisation.oci-containers.containers = {
nginx-proxy-manager = {
autoStart = true;

View file

@ -20,7 +20,7 @@ in
enable = false;
config = {
bluez-monitor.rules = [
bluez-monitor.rules = mkIf config.eboskma.bluetooth.enable [
{
matches = [{ "device.name" = "~bluez_card.*"; }];
actions = {
@ -47,7 +47,7 @@ in
};
environment.etc = {
bluez_monitor = {
bluez_monitor = mkIf config.eboskma.bluetooth.enable {
target = "wireplumber/bluetooth.lua.d/50-bluez-config.lua";
text = ''
bluez_monitor.properties = {

View file

@ -6,7 +6,7 @@ in
{
options.eboskma.users.erwin = { enable = mkEnableOption "user account for Erwin"; };
imports = [ ./desktop.nix ];
imports = [ ./home.nix ./work.nix ];
config = mkIf cfg.enable {

View file

@ -11,7 +11,7 @@ with lib; let
in
{
options.eboskma.users.erwin = {
desktop = mkEnableOption "desktop";
home = mkEnableOption "home profile";
terminal = mkOption {
type = types.str;
default = "foot";
@ -21,7 +21,7 @@ in
config =
mkIf cfg.desktop {
home-manager.users.erwin = mkIf cfg.desktop {
home-manager.users.erwin = {
_module.args.flake-inputs = inputs;
programs.home-manager.enable = true;
@ -88,7 +88,10 @@ in
}
];
};
rofi.enable = true;
rofi = {
enable = true;
package = pkgs.rofi-wayland;
};
vscode.enable = false;
solvespace.enable = true;
ssh.enable = true;

199
users/erwin/work.nix Normal file
View file

@ -0,0 +1,199 @@
{ pkgs, config, lib, inputs, self-overlay, ... }:
with lib;
let
cfg = config.eboskma.users.erwin;
in
{
options.eboskma.users.erwin = {
work = mkEnableOption "work profile";
terminal = mkOption {
type = types.str;
default = "Alacritty";
description = "Terminal emulator to use. Specify the .desktop filename, e.g. 'foot' or 'Alacritty'";
};
};
config = mkIf (cfg.work) {
home-manager.users.erwin = {
_module.args.flake-inputs = inputs;
programs.home-manager.enable = true;
programs.command-not-found.enable = true;
home.username = "erwin";
home.homeDirectory = "/home/erwin";
home.sessionVariables = {
EDITOR = "${config.eboskma.programs.emacs.package}/bin/emacsclient -c";
};
nixpkgs.config = { allowUnfree = true; };
eboskma = {
programs = {
alacritty.enable = true;
bat.enable = true;
dropbox.enable = true;
dunst.enable = true;
emacs = {
enable = true;
daemon = true;
};
firefox = {
enable = true;
work = true;
};
fish.enabel = true;
git = {
enable = true;
name = "Erwin Boskma";
email = "erwin@horus.nu";
signingKey = "~/.ssh/id_ed25519_sk";
signingKeyFormat = "ssh";
};
gpg.enable = true;
i3.enable = true;
mpd.enable = true;
polybar.enable = true;
neovim.enable = true;
rclone = {
enable = true;
mounts = [
{
remote = "org-roam";
local = "/home/erwin/org-roam";
remoteConfig = {
type = "sftp";
host = "zh2088.rsync.net";
user = "zh2088";
key_file = "~/.ssh/rsync-net";
};
}
];
rofi.enable = true;
ssh.enable = true;
zellij.enable = true;
};
};
services = {
xbanish.enable = true;
};
};
home.keyboard = {
layout = "us,us";
variant = "colemak,";
model = "pc105";
options = [ "ctrl:nocaps" "eurosign:5" "lv5:ralt_switch" "lv3:rwin_switch" "grp:shifts_toggle" "grp_led:caps" ];
};
home.packages = with pkgs; [
atool
bandwhich
bitwarden
blink1-tool
bottom
fd
ffmpeg_5-full
git
gnome.nautilus
headsetcontrol
imagemagick
iotop
(jetbrains.clion.override { jdk = pkgs.jetbrains.jdk; })
libnotify
libreoffice-fresh
mpv
nordzy-cursor-theme
onefetch
pamedia
quintom-cursor-theme
procs
recursive
ripgrep
signal-desktop
solo2-cli
units
unzip
xdg-utils
xkb-switch
zeal
]
++ (with gst_all_1; [ gstreamer gstreamer.dev gst-plugins-base gst-plugins-good gst-plugins-bad gst-plugins-ugly gst-libav gst-vaapi ]);
xdg = {
enable = true;
mime.enable = true;
mimeApps = {
enable = true;
defaultApplications = {
"x-scheme-handler/http" = "firefox.desktop";
"x-scheme-handler/https" = "firefox.desktop";
"x-scheme-handler/chrome" = "firefox.desktop";
"x-scheme-handler/terminal" = "${cfg.terminal}.desktop";
"text/html" = "firefox.desktop";
"application/x-extension-htm" = "firefox.desktop";
"application/x-extension-html" = "firefox.desktop";
"application/x-extension-shtml" = "firefox.desktop";
"application/xhtml+xml" = "firefox.desktop";
"application/x-extension-xhtml" = "firefox.desktop";
"application/x-extension-xht" = "firefox.desktop";
};
associations = {
added = {
"image/jpeg" = "feh.desktop";
"image/png" = "feh.desktop";
"image/gif" = "feh.desktop";
"application/zip" = "org.gnome.FileRoller.desktop";
};
};
};
userDirs = {
enable = true;
createDirectories = true;
};
};
gtk = {
enable = true;
theme = {
name = "Arc-Dark";
package = pkgs.arc-theme;
};
iconTheme = {
name = "Papirus-Dark";
package = pkgs.papirus-icon-theme;
};
gtk3 = {
bookmarks = [
"file:///home/erwin/workspace"
];
extraConfig = {
gtk-application-prefer-dark-theme = true;
gtk-cursor-theme-name = "Nordzy-cursors";
};
};
};
imports = [
{
nixpkgs.overlays = [
self-overlay
inputs.ha-now-playing.overlays.${pkgs.system}
inputs.pamedia.overlays.${pkgs.system}
inputs.emacs-overlay.overlay
];
}
] ++ (map (mod: (../../home-manager/modules + "/${mod}")) (builtins.attrNames (builtins.readDir ../../home-manager/modules)));
home.stateVersion = "22.11";
};
programs.wireshark = {
enable = true;
package = pkgs.wireshark;
};
users.groups.wireshark.members = [ "erwin" ];
};
}