Skip to content

Commit c8c1b6e

Browse files
committed
Show battery status in tmux
1 parent 13fc826 commit c8c1b6e

2 files changed

Lines changed: 51 additions & 38 deletions

File tree

home/default.nix

Lines changed: 47 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
pkgs-stable,
44
lib,
55
enableGuiPackages,
6+
showBatteryStatus,
67
...
78
}: {
89
imports = [
@@ -405,44 +406,53 @@
405406
mouse = true;
406407
terminal = "xterm-256color";
407408
sensibleOnTop = true;
408-
plugins = with pkgs; [
409-
{
410-
plugin = tmuxPlugins.continuum;
411-
extraConfig = ''
412-
set -g @continuum-restore 'on'
413-
set -g @continuum-save-interval '60' # minutes
414-
'';
415-
}
416-
{
417-
plugin = tmuxPlugins.catppuccin;
418-
extraConfig = ''
419-
set -g @catppuccin_flavor "mocha"
409+
plugins = with pkgs;
410+
[
411+
{
412+
plugin = tmuxPlugins.continuum;
413+
extraConfig = ''
414+
set -g @continuum-restore 'on'
415+
set -g @continuum-save-interval '60' # minutes
416+
'';
417+
}
418+
{
419+
plugin = tmuxPlugins.catppuccin;
420+
extraConfig = ''
421+
set -g @catppuccin_flavor "mocha"
420422
421-
# See: catppuccin/tmux#409
422-
set -g @catppuccin_window_status_style "custom"
423-
set -g @catppuccin_window_left_separator "#[bg=default,fg=#{@thm_surface_0}]#[bg=#{@thm_surface_0},fg=#{@thm_fg}]"
424-
set -g @catppuccin_window_right_separator "#[bg=default,fg=#{@thm_surface_0}]"
425-
set -g @catppuccin_window_current_left_separator "#[bg=default,fg=#{@thm_mauve}]#[bg=#{@thm_mauve},fg=#{@thm_bg}]"
426-
set -g @catppuccin_window_current_middle_separator "#[fg=#{@thm_mauve}]█"
427-
set -g @catppuccin_window_current_right_separator "#[bg=default,fg=#{@thm_surface_1}]"
428-
set -g @catppuccin_status_background "none"
429-
'';
430-
}
431-
{
432-
plugin = tmuxPlugins.cpu;
433-
# N.B.: extraConfig here applies to catppuccin above; it has to be set _after_ loading catppuccin plugin
434-
extraConfig = ''
435-
set -g status-right-length 100
436-
set -g status-left-length 100
437-
set -g status-left ""
438-
set -g status-right "#{E:@catppuccin_status_application}"
439-
set -ag status-right "#{E:@catppuccin_status_session}"
440-
set -agF status-right "#{E:@catppuccin_status_cpu}"
441-
set -ag status-right "#{E:@catppuccin_status_uptime}"
442-
'';
443-
}
444-
tmuxPlugins.yank
445-
];
423+
# See: catppuccin/tmux#409
424+
set -g @catppuccin_window_status_style "custom"
425+
set -g @catppuccin_window_left_separator "#[bg=default,fg=#{@thm_surface_0}]#[bg=#{@thm_surface_0},fg=#{@thm_fg}]"
426+
set -g @catppuccin_window_right_separator "#[bg=default,fg=#{@thm_surface_0}]"
427+
set -g @catppuccin_window_current_left_separator "#[bg=default,fg=#{@thm_mauve}]#[bg=#{@thm_mauve},fg=#{@thm_bg}]"
428+
set -g @catppuccin_window_current_middle_separator "#[fg=#{@thm_mauve}]█"
429+
set -g @catppuccin_window_current_right_separator "#[bg=default,fg=#{@thm_surface_1}]"
430+
set -g @catppuccin_status_background "none"
431+
'';
432+
}
433+
{
434+
plugin = tmuxPlugins.cpu;
435+
# N.B.: extraConfig here applies to catppuccin above; it has to be set _after_ loading catppuccin plugin
436+
extraConfig = ''
437+
set -g status-right-length 100
438+
set -g status-left-length 100
439+
set -g status-left ""
440+
set -g status-right "#{E:@catppuccin_status_application}"
441+
set -ag status-right "#{E:@catppuccin_status_session}"
442+
set -agF status-right "#{E:@catppuccin_status_cpu}"
443+
set -ag status-right "#{E:@catppuccin_status_uptime}"
444+
'';
445+
}
446+
tmuxPlugins.yank
447+
]
448+
++ lib.optionals showBatteryStatus [
449+
{
450+
plugin = tmuxPlugins.battery;
451+
extraConfig = ''
452+
set -agF status-right "#{E:@catppuccin_status_battery}"
453+
'';
454+
}
455+
];
446456
extraConfig = ''
447457
# See: tmux/tmux#696
448458
set-option -ga terminal-overrides ",xterm-256color:Tc"

lib/hosts.nix

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
hostname,
2525
system,
2626
enableGuiPackages,
27+
showBatteryStatus,
2728
}: let
2829
pkgs-stable = import nixpkgs-stable {inherit system;};
2930
hostHomePath = ./../hosts/${hostname}/home.nix;
@@ -45,7 +46,7 @@
4546
}
4647
else import ./../home;
4748
home-manager.extraSpecialArgs = {
48-
inherit pkgs-stable enableGuiPackages;
49+
inherit pkgs-stable enableGuiPackages showBatteryStatus;
4950
};
5051
};
5152

@@ -81,6 +82,7 @@
8182
(mkHomeManager {
8283
inherit username hostname system;
8384
enableGuiPackages = false;
85+
showBatteryStatus = false;
8486
})
8587
{
8688
nixpkgs.overlays = overlays;
@@ -120,6 +122,7 @@
120122
(mkHomeManager {
121123
inherit username hostname system;
122124
enableGuiPackages = true;
125+
showBatteryStatus = true;
123126
})
124127
{
125128
home-manager.sharedModules = [

0 commit comments

Comments
 (0)