add a package count status item, useful for minimal containers

This commit is contained in:
Dustin Kirkland 2023-12-25 06:59:26 -06:00
parent d894c95e7e
commit b2f15f9ca5
5 changed files with 64 additions and 7 deletions

View file

@ -1,3 +1,3 @@
libdirdir = $(prefix)/lib/@PACKAGE@
libdir_SCRIPTS = apport arch battery cpu_count cpu_freq cpu_temp color custom date disk disk_io distro entropy fan_speed hostname ip_address load_average logo mail memory menu network processes raid reboot_required release services session swap time time_binary time_utc trash updates_available uptime users whoami wifi_quality
libdir_SCRIPTS = apport arch battery cpu_count cpu_freq cpu_temp color custom date disk disk_io distro entropy fan_speed hostname ip_address load_average logo mail memory menu network packages processes raid reboot_required release services session swap time time_binary time_utc trash updates_available uptime users whoami wifi_quality

View file

@ -258,6 +258,7 @@ status_freq() {
menu) _RET=9999991 ;;
network) _RET=3 ;;
notify_osd) _RET=9999991 ;;
packages) _RET=211 ;;
processes) _RET=7 ;;
raid) _RET=59 ;;
reboot_required) _RET=5 ;;

53
usr/lib/byobu/packages Executable file
View file

@ -0,0 +1,53 @@
#!/bin/sh -e
#
# packages: count the number of packages installed
#
# Copyright (C) 2023 Dustin Kirkland
#
# Authors: Dustin Kirkland <kirkland@byobu.org>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, version 3 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
__packages_detail() {
if eval $BYOBU_TEST dpkg >/dev/null 2>&1; then
dpkg -l | grep ^ii
fi
if eval $BYOBU_TEST snap >/dev/null 2>&1; then
snap list
fi
if eval $BYOBU_TEST apk >/dev/null 2>&1; then
apk info
fi
return
}
__packages() {
local packages=0
if eval $BYOBU_TEST dpkg >/dev/null 2>&1; then
count=$(dpkg -l | grep -c ^ii)
packages=$((packages+count))
fi
if eval $BYOBU_TEST snap >/dev/null 2>&1; then
count=$(snap list | grep -c -v "^Name\s")
packages=$((packages+count))
fi
if eval $BYOBU_TEST apk >/dev/null 2>&1; then
count=$(apk info | wc -l)
packages=$((packages+count))
fi
[ -n "$packages" ] || return
color w y; printf "[%s]" "$count"; color -;
}
# vi: syntax=sh ts=4 noexpandtab

View file

@ -5,6 +5,7 @@
# and $HOME/.byobu otherwise.
#
# Copyright (C) 2009-2011 Canonical Ltd.
# Copyright (C) 2023 Dustin Kirkland
#
# Authors: Dustin Kirkland <kirkland@byobu.org>
#
@ -26,13 +27,13 @@
screen_upper_left="color"
screen_upper_right="color whoami hostname ip_address menu"
screen_lower_left="color logo distro release #arch session"
screen_lower_right="color network #disk_io custom #entropy raid reboot_required updates_available #apport #services #mail users uptime #fan_speed #cpu_temp battery wifi_quality #processes load_average cpu_count cpu_freq memory #swap disk #time_utc date time"
screen_lower_right="color network #disk_io custom #entropy raid reboot_required updates_available #apport #services #mail users uptime #fan_speed #cpu_temp battery wifi_quality #processes #packages load_average cpu_count cpu_freq memory #swap disk #time_utc date time"
# Tmux has one status line, with 2 halves for status
tmux_left="logo #distro release #arch session"
# You can have as many tmux right lines below here, and cycle through them using Shift-F5
tmux_right="#network #disk_io #custom #entropy raid reboot_required updates_available #apport #services #mail #users uptime #fan_speed #cpu_temp #battery #wifi_quality #processes load_average cpu_count cpu_freq memory #swap disk #whoami #hostname #ip_address #time_utc date time"
#tmux_right="network disk_io uptime processes load_average cpu_count cpu_freq memory disk date time" # Tailored for inside of containers
#tmux_right="network #disk_io #custom entropy raid reboot_required updates_available #apport #services #mail users uptime fan_speed cpu_temp battery wifi_quality #processes load_average cpu_count cpu_freq memory #swap #disk whoami hostname ip_address #time_utc date time"
#tmux_right="network #disk_io custom #entropy raid reboot_required updates_available #apport #services #mail users uptime #fan_speed #cpu_temp battery wifi_quality #processes load_average cpu_count cpu_freq memory #swap #disk #whoami #hostname ip_address #time_utc date time"
#tmux_right="#network disk_io #custom entropy #raid #reboot_required #updates_available #apport #services #mail #users #uptime fan_speed cpu_temp #battery #wifi_quality #processes #load_average #cpu_count #cpu_freq #memory #swap whoami hostname ip_address #time_utc disk date time"
tmux_right="#network #disk_io #custom #entropy raid reboot_required updates_available #apport #services #mail #users uptime #fan_speed #cpu_temp #battery #wifi_quality #processes #packages load_average cpu_count cpu_freq memory #swap disk #whoami #hostname #ip_address #time_utc date time"
#tmux_right="network disk_io uptime processes packages load_average cpu_count cpu_freq memory disk date time" # Tailored for inside of containers
#tmux_right="network #disk_io #custom entropy raid reboot_required updates_available #apport #services #mail users uptime fan_speed cpu_temp battery wifi_quality #processes #packages load_average cpu_count cpu_freq memory #swap #disk whoami hostname ip_address #time_utc date time"
#tmux_right="network #disk_io custom #entropy raid reboot_required updates_available #apport #services #mail users uptime #fan_speed #cpu_temp battery wifi_quality #processes #packages load_average cpu_count cpu_freq memory #swap #disk #whoami #hostname ip_address #time_utc date time"
#tmux_right="#network disk_io #custom entropy #raid #reboot_required #updates_available #apport #services #mail #users #uptime fan_speed cpu_temp #battery #wifi_quality #processes #packages #load_average #cpu_count #cpu_freq #memory #swap whoami hostname ip_address #time_utc disk date time"

View file

@ -79,6 +79,8 @@ The background colors of the \fBbyobu\fP status lines can be adjusted by editing
\fBnotify_osd\fP \- Send on-screen notification messages to screen's notification buffer
\fBpackages\fP \- total number of packages installed on the system; displayed in the lower bar in yellow text on a white background inside of square brackets, '[xxx]'
\fBprocesses\fP \- total number of processes running on the system; displayed in the lower bar in white text on a dark yellow background with a trailing '&' indicating 'background processes'
\fBreboot_required\fP \- symbol present if a reboot is required following a system update; displayed in the lower bar white text on a blue background by the symbol '(R)'; additionally, reboot_required will print '<F5>' in white text on a blue background, if Byobu requires you to reload your profile to affect some changes; it will also detect if your system is currently in \fBpowernap\fP(8) state and if so print '.zZ'; if your system is currently performing an \fBunattended-upgrade\fP(1) you will see a white warning sign on a red background.