diff --git a/dotfiles/lib/functions/multiplexer_host_label b/dotfiles/lib/functions/multiplexer_host_label new file mode 100755 index 00000000..b2578b48 --- /dev/null +++ b/dotfiles/lib/functions/multiplexer_host_label @@ -0,0 +1,30 @@ +#!/usr/bin/env sh + +multiplexer_host_label() { + tmux_format=0 + if [ "$1" = "--tmux" ]; then + tmux_format=1 + shift + fi + + host=$(hostname -s 2>/dev/null || hostname 2>/dev/null || printf unknown) + host=${host%%.*} + + identity_file=${MULTIPLEXER_HOST_IDENTITY_FILE:-/etc/multiplexer-host-identity} + if [ -r "$identity_file" ]; then + # shellcheck disable=SC1090 + . "$identity_file" + fi + + icon=${MULTIPLEXER_HOST_ICON:-🖥️} + tmux_bg=${MULTIPLEXER_HOST_TMUX_BG:-#222222} + tmux_fg=${MULTIPLEXER_HOST_TMUX_FG:-#ffffff} + + if [ "$tmux_format" -eq 1 ]; then + printf '#[fg=%s,bg=%s,bold]%s %s#[default]' "$tmux_fg" "$tmux_bg" "$icon" "$host" + else + printf '%s %s' "$icon" "$host" + fi +} + +multiplexer_host_label "$@" diff --git a/dotfiles/tmux.conf b/dotfiles/tmux.conf index 479a318b..32ee14eb 100644 --- a/dotfiles/tmux.conf +++ b/dotfiles/tmux.conf @@ -2,7 +2,9 @@ # Prefix + C starts a new session without prompting for a name. bind-key C new-session -c '#{pane_current_path}' 'codex --dangerously-bypass-approvals-and-sandbox' -set -g status-right '#($HOME/dotfiles/dotfiles/lib/functions/multiplexer_host_label 2>/dev/null || multiplexer_host_label 2>/dev/null || hostname -s) #{?window_bigger,[#{window_offset_x}#,#{window_offset_y}] ,}"#{=21:pane_title}" %H:%M %d-%b-%y' +source-file -q /etc/tmux-host-style.conf + +set -g status-right '#($HOME/dotfiles/dotfiles/lib/functions/multiplexer_host_label --tmux 2>/dev/null || multiplexer_host_label --tmux 2>/dev/null || hostname -s) #{?window_bigger,[#{window_offset_x}#,#{window_offset_y}] ,}"#{=21:pane_title}" %H:%M %d-%b-%y' set -g status-right-length 150 set -g set-titles on set -g set-titles-string '#{?#{==:#{session_name},#{window_name}},#{session_name},#{session_name}:#{window_name}}#{?pane_title, - #{pane_title},}' diff --git a/dotfiles/tmux.powerline b/dotfiles/tmux.powerline index d9325ed9..d54827b8 100644 --- a/dotfiles/tmux.powerline +++ b/dotfiles/tmux.powerline @@ -1,11 +1,12 @@ if-shell 'test -z "$POWERLINE_COMMAND"' 'if-shell "which powerline-client" "set-environment -g POWERLINE_COMMAND powerline-client" "set-environment -g POWERLINE_COMMAND powerline"' +source-file -q /etc/tmux-host-style.conf set -g status on set -g status-utf8 on set -g status-interval 2 set -g status-justify left set -g status-left-length 150 set -g status-right-length 150 -set -g status-right '#(eval $POWERLINE_COMMAND tmux right -R pane_id=`tmux display -p "#D"`)' +set -g status-right '#($HOME/dotfiles/dotfiles/lib/functions/multiplexer_host_label --tmux 2>/dev/null || multiplexer_host_label --tmux 2>/dev/null || hostname -s) #(eval $POWERLINE_COMMAND tmux right -R pane_id=`tmux display -p "#D"`)' set -g window-status-format "#[fg=white] #[fg=white,bg=black]#I #[fg=white] #[default]#W " set -g window-status-current-format "#[fg=black,bg=blue]#[fg=white,bg=blue] #I  #[fg=white,bold]#W #[fg=blue,bg=black,nobold]" set-window-option -g window-status-fg white diff --git a/nixos/machines/adell.nix b/nixos/machines/adell.nix index fb50336a..2400b967 100644 --- a/nixos/machines/adell.nix +++ b/nixos/machines/adell.nix @@ -71,6 +71,10 @@ swapDevices = []; networking.hostName = "adell"; + myModules.hostIdentity = { + emoticon = "💻"; + tmux.background = "#7c3aed"; + }; powerManagement.cpuFreqGovernor = lib.mkDefault "performance"; diff --git a/nixos/machines/bencbox.nix b/nixos/machines/bencbox.nix index 2e2a8281..ac829def 100644 --- a/nixos/machines/bencbox.nix +++ b/nixos/machines/bencbox.nix @@ -19,6 +19,10 @@ myModules.wsl.enable = true; networking.hostName = "bencbox"; + myModules.hostIdentity = { + emoticon = "📦"; + tmux.background = "#b45309"; + }; wsl.defaultUser = "ben"; system.stateVersion = "22.05"; diff --git a/nixos/machines/biskcomp.nix b/nixos/machines/biskcomp.nix index e91aebc0..c4e31f99 100644 --- a/nixos/machines/biskcomp.nix +++ b/nixos/machines/biskcomp.nix @@ -162,6 +162,10 @@ in { ]; networking.hostName = "biskcomp"; + myModules.hostIdentity = { + emoticon = "🧮"; + tmux.background = "#0f766e"; + }; system.stateVersion = "23.11"; home-manager.sharedModules = [ diff --git a/nixos/machines/david-blade.nix b/nixos/machines/david-blade.nix index 166011aa..0c22b2df 100644 --- a/nixos/machines/david-blade.nix +++ b/nixos/machines/david-blade.nix @@ -55,6 +55,10 @@ ]; networking.hostName = "david-blade"; + myModules.hostIdentity = { + emoticon = "🗡️"; + tmux.background = "#be123c"; + }; home-manager.sharedModules = [ { diff --git a/nixos/machines/dean-zephyrus.nix b/nixos/machines/dean-zephyrus.nix index 4deb9a6f..3c9a13b9 100644 --- a/nixos/machines/dean-zephyrus.nix +++ b/nixos/machines/dean-zephyrus.nix @@ -16,6 +16,10 @@ myModules.wsl.enable = true; networking.hostName = "dean-zephyrus"; + myModules.hostIdentity = { + emoticon = "🌬️"; + tmux.background = "#0284c7"; + }; wsl.defaultUser = "dean"; system.stateVersion = "22.05"; diff --git a/nixos/machines/jay-lenovo-wsl.nix b/nixos/machines/jay-lenovo-wsl.nix index 4c23b86b..f63cb193 100644 --- a/nixos/machines/jay-lenovo-wsl.nix +++ b/nixos/machines/jay-lenovo-wsl.nix @@ -13,6 +13,10 @@ myModules.wsl.enable = true; networking.hostName = "jay-lenovo-wsl"; + myModules.hostIdentity = { + emoticon = "💼"; + tmux.background = "#15803d"; + }; wsl.defaultUser = "kat"; system.stateVersion = "22.05"; diff --git a/nixos/machines/jay-lenovo.nix b/nixos/machines/jay-lenovo.nix index 3bde6bab..6b59c7ef 100644 --- a/nixos/machines/jay-lenovo.nix +++ b/nixos/machines/jay-lenovo.nix @@ -58,6 +58,10 @@ }; networking.hostName = "jay-lenovo"; + myModules.hostIdentity = { + emoticon = "💼"; + tmux.background = "#16a34a"; + }; services.power-profiles-daemon.enable = false; services.tlp.enable = true; diff --git a/nixos/machines/jimi-hendnix.nix b/nixos/machines/jimi-hendnix.nix index 9f912161..76f63c2b 100644 --- a/nixos/machines/jimi-hendnix.nix +++ b/nixos/machines/jimi-hendnix.nix @@ -120,6 +120,11 @@ ]; networking.hostName = "jimi-hendnix"; + myModules.hostIdentity = { + emoticon = "🎸"; + tmux.background = "#ca8a04"; + tmux.foreground = "#111111"; + }; system.stateVersion = "23.05"; } diff --git a/nixos/machines/justin-bieber-creek.nix b/nixos/machines/justin-bieber-creek.nix index 4e69c5a2..47807848 100644 --- a/nixos/machines/justin-bieber-creek.nix +++ b/nixos/machines/justin-bieber-creek.nix @@ -198,6 +198,10 @@ swapDevices = []; networking.hostName = "justin-bieber-creek"; + myModules.hostIdentity = { + emoticon = "🎤"; + tmux.background = "#c026d3"; + }; networking.useDHCP = false; nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; diff --git a/nixos/machines/nixquick.nix b/nixos/machines/nixquick.nix index cd8cbde6..21e53824 100644 --- a/nixos/machines/nixquick.nix +++ b/nixos/machines/nixquick.nix @@ -32,6 +32,10 @@ services.k3s.enable = lib.mkForce false; networking.hostName = "nixquick"; + myModules.hostIdentity = { + emoticon = "🐩"; + tmux.background = "#db2777"; + }; hardware.enableRedistributableFirmware = true; boot.initrd.availableKernelModules = ["xhci_pci" "ahci" "nvme" "usbhid" "usb_storage" "sd_mod"]; diff --git a/nixos/machines/railbird-sf.nix b/nixos/machines/railbird-sf.nix index 12a2b237..3160ce59 100644 --- a/nixos/machines/railbird-sf.nix +++ b/nixos/machines/railbird-sf.nix @@ -13,6 +13,10 @@ ]; networking.hostName = "railbird-sf"; + myModules.hostIdentity = { + emoticon = "🐦"; + tmux.background = "#0891b2"; + }; # Allow nginx to serve content synced into /var/lib/syncthing/* (owned by syncthing:syncthing, 2770 perms). users.users.nginx.extraGroups = ["syncthing"]; diff --git a/nixos/machines/ryzen-shine-original.nix b/nixos/machines/ryzen-shine-original.nix index 5a3fd70d..a20ef0b5 100644 --- a/nixos/machines/ryzen-shine-original.nix +++ b/nixos/machines/ryzen-shine-original.nix @@ -26,6 +26,10 @@ boot.loader.systemd-boot.configurationLimit = 5; networking.hostName = "ryzen-shine"; + myModules.hostIdentity = { + emoticon = "☀️"; + tmux.background = "#ea580c"; + }; environment.systemPackages = with pkgs; [ perf diff --git a/nixos/machines/ryzen-shine-wsl.nix b/nixos/machines/ryzen-shine-wsl.nix index ba7b0679..197075b1 100644 --- a/nixos/machines/ryzen-shine-wsl.nix +++ b/nixos/machines/ryzen-shine-wsl.nix @@ -19,6 +19,10 @@ myModules.wsl.enable = true; networking.hostName = "ryzen-shine-wsl"; + myModules.hostIdentity = { + emoticon = "☀️"; + tmux.background = "#f97316"; + }; wsl.defaultUser = "imalison"; system.stateVersion = "22.05"; diff --git a/nixos/machines/ryzen-shine.nix b/nixos/machines/ryzen-shine.nix index 374448b5..9401f0d6 100644 --- a/nixos/machines/ryzen-shine.nix +++ b/nixos/machines/ryzen-shine.nix @@ -47,6 +47,10 @@ }; networking.hostName = "ryzen-shine"; + myModules.hostIdentity = { + emoticon = "☀️"; + tmux.background = "#ea580c"; + }; environment.systemPackages = with pkgs; [ perf diff --git a/nixos/machines/strixi-minaj-wsl.nix b/nixos/machines/strixi-minaj-wsl.nix index 897de012..de961391 100644 --- a/nixos/machines/strixi-minaj-wsl.nix +++ b/nixos/machines/strixi-minaj-wsl.nix @@ -12,6 +12,10 @@ myModules.wsl.enable = true; networking.hostName = "strixi-minaj-wsl"; + myModules.hostIdentity = { + emoticon = "👩🏿"; + tmux.background = "#4338ca"; + }; wsl.defaultUser = "imalison"; system.stateVersion = "23.11"; # Did you read the comment? diff --git a/nixos/machines/strixi-minaj.nix b/nixos/machines/strixi-minaj.nix index 2312dfaa..bf2b3c38 100644 --- a/nixos/machines/strixi-minaj.nix +++ b/nixos/machines/strixi-minaj.nix @@ -103,6 +103,10 @@ ]; networking.hostName = "strixi-minaj"; + myModules.hostIdentity = { + emoticon = "👩🏿"; + tmux.background = "#4f46e5"; + }; powerManagement.cpuFreqGovernor = lib.mkDefault "performance"; hardware.cpu.intel.updateMicrocode = lib.mkDefault true; diff --git a/nixos/options.nix b/nixos/options.nix index 0d240aee..73f49e02 100644 --- a/nixos/options.nix +++ b/nixos/options.nix @@ -1,8 +1,50 @@ -{lib, ...}: { +{ + config, + lib, + ... +}: let + hostIdentity = config.myModules.hostIdentity; +in { options = { + myModules.hostIdentity = { + emoticon = lib.mkOption { + type = lib.types.str; + default = "🖥️"; + description = "Short visual marker used when displaying this host in multiplexer status bars."; + }; + + tmux = { + background = lib.mkOption { + type = lib.types.str; + default = "#222222"; + description = "tmux status bar background color for this host."; + }; + + foreground = lib.mkOption { + type = lib.types.str; + default = "#ffffff"; + description = "tmux status bar foreground color for this host."; + }; + }; + }; + myModules.xmonad.picom.vSync.enable = lib.mkOption { default = true; type = lib.types.bool; }; }; + + config = { + environment.etc."multiplexer-host-identity".text = '' + MULTIPLEXER_HOST_ICON=${lib.escapeShellArg hostIdentity.emoticon} + MULTIPLEXER_HOST_TMUX_BG=${lib.escapeShellArg hostIdentity.tmux.background} + MULTIPLEXER_HOST_TMUX_FG=${lib.escapeShellArg hostIdentity.tmux.foreground} + ''; + + environment.etc."tmux-host-style.conf".text = '' + set -g status-style "fg=${hostIdentity.tmux.foreground},bg=${hostIdentity.tmux.background}" + set -g status-left-style "fg=${hostIdentity.tmux.foreground},bg=${hostIdentity.tmux.background}" + set -g status-right-style "fg=${hostIdentity.tmux.foreground},bg=${hostIdentity.tmux.background}" + ''; + }; }