mirror of
https://github.com/dustinkirkland/byobu
synced 2025-08-22 14:24:39 -07:00
bin/custom, byobu-config, byobu.1, profiles/common, rpm/byobu.spec,
statusrc: add support for a custom status script indicator
This commit is contained in:
parent
f5f0d15296
commit
f1d0f98a85
7 changed files with 58 additions and 1 deletions
48
bin/custom
Executable file
48
bin/custom
Executable file
|
@ -0,0 +1,48 @@
|
|||
#!/bin/sh -e
|
||||
#
|
||||
# custom: run the user's custom status scripts
|
||||
#
|
||||
# Copyright (C) 2009 Canonical Ltd.
|
||||
#
|
||||
# Authors: Dustin Kirkland <kirkland@canonical.com>
|
||||
#
|
||||
# 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/>.
|
||||
|
||||
PKG="byobu"
|
||||
[ -d "$HOME/.$PKG/bin" ] || exit 0
|
||||
|
||||
[ -r "/etc/$PKG/statusrc" ] && . "/etc/$PKG/statusrc"
|
||||
[ -d "/var/run/screen/S-$USER" ] && DIR="/var/run/screen/S-$USER" || DIR="$HOME/.byobu"
|
||||
NOW=$(date +%s)
|
||||
CACHE="$DIR/$PKG.custom"
|
||||
|
||||
# Loop over custom scripts
|
||||
for i in $(ls "$HOME/.$PKG/bin/"[0-9]*_* 2>/dev/null); do
|
||||
[ -x "$i" ] || continue
|
||||
script=$(basename "$i")
|
||||
freq=$(echo "$script" | awk -F_ '{print $1}')
|
||||
lastrun=$(stat -c %Y "$CACHE.$script") 2>/dev/null || lastrun=0
|
||||
expiration=$(expr $lastrun + $freq)
|
||||
if [ $NOW -ge $expiration ]; then
|
||||
# Update the cache
|
||||
$i > "$CACHE.$script" 2>/dev/null
|
||||
fi
|
||||
output=$(cat "$CACHE.$script")
|
||||
if echo "$output" | grep -qs "$ESC{"; then
|
||||
# User has formatted the colors
|
||||
echo "$output"
|
||||
else
|
||||
# Default to inverted coloring
|
||||
echo "$INVERT$output$UNDO "
|
||||
fi
|
||||
done
|
|
@ -276,6 +276,7 @@ def readstatus():
|
|||
status["battery"]=0
|
||||
status["cpu_count"]=1
|
||||
status["cpu_freq"]=1
|
||||
status["custom"]=1
|
||||
status["date"]=1
|
||||
status["disk"]=0
|
||||
status["ec2_cost"]=0
|
||||
|
|
2
byobu.1
2
byobu.1
|
@ -19,6 +19,8 @@ byobu \- wrapper script for seeding a user's byobu configuration and launching s
|
|||
|
||||
\fBcpu_freq\fP \- the current frequency of the cpu in GHz; displayed in the lower bar toward the right in white text on a light blue background
|
||||
|
||||
\fBcustom\fP \- user defined custom scripts; must be executable programs of any kind in \fI$HOME/.byobu/bin\fP; must be named N_NAME, where N is the frequency in seconds to refresh the status indicator, and NAME is the name of the script; N should not be less than 5 seconds; script should echo a small amount of text to standard out, standard error is discared; the indicator will be displayed in the lower panel, in inverted colors to your current background/foreground scheme, unless you manually specify the colors in your script's output; BEWARE, cpu-intensive custom scripts may impact your overall system performance and could upset your system administrator!
|
||||
|
||||
\fBdate\fP \- the system date in YYYY-MM-DD formate; displayed in the lower on the far right in the default text color on the default background
|
||||
|
||||
\fBdisk\fP \- total disk space available and total used on / directory; displayed in the lower bar on the far right in white text on a light purple background; override the default directory by specifying an alternate mount point with MONITORED_DISK=/wherever in \fI$HOME/.byobu/statusrc\fP
|
||||
|
|
2
debian/changelog
vendored
2
debian/changelog
vendored
|
@ -45,6 +45,8 @@ byobu (2.40) unreleased; urgency=low
|
|||
there are noisy complaints
|
||||
* byobu-janitor, statusrc: seed the ~/.byobu/status file with the
|
||||
default values, making it easier for users to customize themselves
|
||||
* bin/custom, byobu-config, byobu.1, profiles/common, rpm/byobu.spec,
|
||||
statusrc: add support for a custom status script indicator
|
||||
|
||||
-- Dustin Kirkland <kirkland@ubuntu.com> Tue, 10 Nov 2009 10:18:20 -0600
|
||||
|
||||
|
|
|
@ -67,6 +67,7 @@ backtick 126 19 19 byobu-status temp_f
|
|||
backtick 127 5 5 byobu-status mail
|
||||
backtick 128 23 23 byobu-status fan_speed
|
||||
backtick 129 67 67 byobu-status apport
|
||||
backtick 130 5 5 byobu-status custom
|
||||
|
||||
hardstatus alwayslastline
|
||||
|
||||
|
@ -92,7 +93,7 @@ source $HOME/.byobu/keybindings
|
|||
caption always "%12`%?%-Lw%50L>%?%{=r }%{+b }%n*%f %t%?(%u)%?%12`%?%+Lw%?%11` %=%12`%110`%109`%122`%111`%10`%<"
|
||||
|
||||
# Status string, last line
|
||||
hardstatus string '%99`%12` %100`%112`%= %102`%101`%129`%127`%114`%115`%108`%128`%125`%126`%113`%119`%117`%116`%106`%104`%103`%105`%107`%123`%120`%121`'
|
||||
hardstatus string '%99`%12` %100`%112`%= %130`%102`%101`%129`%127`%114`%115`%108`%128`%125`%126`%113`%119`%117`%116`%106`%104`%103`%105`%107`%123`%120`%121`'
|
||||
|
||||
# NOTE: Older version of screen have an arbitrary limit of only being able
|
||||
# to change colors 16 times in this 'hardstatus string'.
|
||||
|
|
|
@ -86,6 +86,7 @@ rm -rf $RPM_BUILD_ROOT
|
|||
/usr/lib/byobu/battery
|
||||
/usr/lib/byobu/cpu_count
|
||||
/usr/lib/byobu/cpu_freq
|
||||
/usr/lib/byobu/custom
|
||||
/usr/lib/byobu/date
|
||||
/usr/lib/byobu/disk
|
||||
/usr/lib/byobu/ec2_cost
|
||||
|
|
2
statusrc
2
statusrc
|
@ -25,6 +25,7 @@ arch=0
|
|||
battery=0
|
||||
cpu_count=1
|
||||
cpu_freq=1
|
||||
custom=1
|
||||
date=1
|
||||
disk=0
|
||||
ec2_cost=0
|
||||
|
@ -65,6 +66,7 @@ UNDO="$ESC{-}"
|
|||
BOLD1="$ESC{=b }"
|
||||
BOLD2="$ESC{+b }"
|
||||
NONE="$ESC{= }"
|
||||
INVERT="$ESC{=r }"
|
||||
|
||||
bw="$ESC{= bw}"
|
||||
bW="$ESC{= bW}"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue