[ Raphaël Pinson and Dustin Kirkland ]

bin/battery, bin/users, bin/uptime, profiles/common, screen-profiles:
added new status items for battery state, number of users, and system
uptime
-Dustin Kirkland <kirkland@ubuntu.com>Fri, 03 Apr 2009 10:45:36 -0500
This commit is contained in:
Dustin Kirkland 2009-04-03 11:04:10 -05:00
commit f4d6f7dc65
10 changed files with 217 additions and 56 deletions

87
bin/battery Executable file
View file

@ -0,0 +1,87 @@
#!/bin/sh -e
#
# battery: print the state of the battery
# Copyright (C) 2009 Raphaël Pinson.
#
# Authors: Raphaël Pinson <raphink@ubuntu.com>
# 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/>.
#
# Default is "off"
p="battery"
grep -qs "^$p=1$" "$HOME/.screen-profiles/status" || exit 0
search () {
local str expr
str="$1"
expr="$2"
echo "$str" | sed -n "s/${expr}/\1/p"
}
BATS=$(ls /proc/acpi/battery)
NB=$(echo "$BATS" | wc -l)
for bat in $BATS; do
if [ "$NB" -gt 1 ]; then
echo -n "$bat: "
fi
# read files once
infofile=$(cat "/proc/acpi/battery/$bat/info")
statefile=$(cat "/proc/acpi/battery/$bat/state")
present=$(search "$infofile" "present: *\(.*\)")
if [ "x${present}" = "xno" ]; then
echo "n/a"
break
fi
full=$(search "$infofile" "last full capacity: *\(.*\) m[AW]h")
warn=$(search "$infofile" "design capacity warning: \(.*\) m[AW]h")
low=$(search "$infofile" "design capacity low: \(.*\) m[AW]h")
rem=$(search "$statefile" "remaining capacity: *\(.*\) m[AW]h")
if [ "$rem" -lt "$low" ]; then
color="{= rk}"
elif [ "$rem" -lt "$warn" ]; then
color="{= yk}"
else
color="{= Gk}"
fi
percent=$(echo "100*$rem/$full" | bc)
state=$(search "$statefile" "charging state: *\(.*\)")
case $state in
charging)
sign="+"
;;
discharging)
sign="-"
;;
charged)
sign="="
;;
*)
sign="$state"
;;
esac
printf "\005%s|%s|%d%%\005{-} " "$color" "$sign" "$percent"
done

36
bin/uptime Executable file
View file

@ -0,0 +1,36 @@
#!/bin/sh -e
#
# uptime: condensed uptime of the machine
# Copyright (C) 2009 Raphaël Pinson.
# Copyright (C) 2009 Canonical Ltd.
#
# Authors: Raphaël Pinson <raphink@ubuntu.com>
# 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/>.
#
# Default is "off"
p="uptime"
grep -qs "^$p=1$" "$HOME/.screen-profiles/status" || exit 0
u=$(sed "s/\..*$//" /proc/uptime)
if [ "$u" -gt 86400 ]; then
printf "%dd" `echo "$u" | awk '{printf "%.0f", $1 / 86400 }'`
elif [ "$u" -gt 3600 ]; then
printf "%dh" `echo "$u" | awk '{printf "%.0f", $1 / 3600 }'`
elif [ "$u" -gt 60 ]; then
printf "%dm" `echo "$u" | awk '{printf "%.0f", $1 / 60 }'`
else
printf "%ds" "$u"
fi

27
bin/users Executable file
View file

@ -0,0 +1,27 @@
#!/bin/sh -e
#
# users: print the number of users on the machine
# Copyright (C) 2009 Raphaël Pinson.
# Copyright (C) 2009 Canonical Ltd.
#
# Authors: Raphaël Pinson <raphink@ubuntu.com>
# 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/>.
#
# Default is "off"
p="users"
grep -qs "^$p=1$" "$HOME/.screen-profiles/status" || exit 0
printf "#%d\005{-} " `who | wc -l`

7
debian/changelog vendored
View file

@ -3,7 +3,12 @@ screen-profiles (1.43) unreleased; urgency=low
* UNRELEASED
* bin/logo: allow users to define their own logo
-- Dustin Kirkland <kirkland@ubuntu.com> Wed, 01 Apr 2009 11:23:13 -0500
[ Raphaël Pinson and Dustin Kirkland ]
* bin/battery, bin/users, bin/uptime, profiles/common, screen-profiles:
added new status items for battery state, number of users, and system
uptime
-- Dustin Kirkland <kirkland@ubuntu.com> Fri, 03 Apr 2009 10:45:36 -0500
screen-profiles (1.42-0ubuntu1) jaunty; urgency=low

View file

@ -3,13 +3,13 @@
# This file is distributed under the same license as the GNU Screen Profiles package.
# Nicolas Valcarcel <nvalcarcel@ubuntu.com>, 2008.
#
#: screen-profiles:297
#: screen-profiles:300
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: 1.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2009-03-31 17:36-0500\n"
"POT-Creation-Date: 2009-04-03 11:01-0500\n"
"PO-Revision-Date: 2008-12-22 01:01-0500\n"
"Last-Translator: Nicolas Valcarcel <nvalcarcel@ubuntu.com>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@ -57,7 +57,7 @@ msgstr ""
msgid "Exit"
msgstr ""
#: screen-profiles:87 screen-profiles:463
#: screen-profiles:87 screen-profiles:466
msgid " Screen Profiles Configuration Menu"
msgstr ""
@ -66,14 +66,14 @@ msgid "Okay"
msgstr ""
#: screen-profiles:98 screen-profiles:134 screen-profiles:150
#: screen-profiles:185 screen-profiles:304 screen-profiles:346
#: screen-profiles:424
#: screen-profiles:185 screen-profiles:307 screen-profiles:349
#: screen-profiles:427
msgid "Cancel"
msgstr ""
#: screen-profiles:116 screen-profiles:143 screen-profiles:157
#: screen-profiles:317 screen-profiles:371 screen-profiles:379
#: screen-profiles:452
#: screen-profiles:320 screen-profiles:374 screen-profiles:382
#: screen-profiles:455
msgid "Menu"
msgstr ""
@ -82,7 +82,7 @@ msgid "Screen Profiles Help"
msgstr ""
#: screen-profiles:134 screen-profiles:150 screen-profiles:185
#: screen-profiles:304 screen-profiles:346 screen-profiles:424
#: screen-profiles:307 screen-profiles:349 screen-profiles:427
msgid "Apply"
msgstr ""
@ -90,8 +90,8 @@ msgstr ""
msgid "Which profile would you like to use?"
msgstr ""
#: screen-profiles:142 screen-profiles:156 screen-profiles:316
#: screen-profiles:378 screen-profiles:450
#: screen-profiles:142 screen-profiles:156 screen-profiles:319
#: screen-profiles:381 screen-profiles:453
msgid "Message"
msgstr ""
@ -119,35 +119,35 @@ msgstr ""
msgid "Create new window(s):"
msgstr ""
#: screen-profiles:305
#: screen-profiles:308
msgid "Toggle status notifications:"
msgstr ""
#: screen-profiles:338
#: screen-profiles:341
msgid "Windows:"
msgstr ""
#: screen-profiles:348
#: screen-profiles:351
msgid "Select window(s) to create by default:"
msgstr ""
#: screen-profiles:368
#: screen-profiles:371
msgid "Screen will be launched automatically next time you login."
msgstr ""
#: screen-profiles:376
#: screen-profiles:379
msgid "Screen will not be used next time you login."
msgstr ""
#: screen-profiles:423
#: screen-profiles:426
msgid "Escape key: ctrl-"
msgstr ""
#: screen-profiles:426
#: screen-profiles:429
msgid "Change escape sequence:"
msgstr ""
#: screen-profiles:464
#: screen-profiles:467
msgid "<Tab>/<Alt-Tab> between elements | <Return> Validates"
msgstr ""

View file

@ -3,13 +3,13 @@
# This file is distributed under the same license as the GNU Screen Profiles package.
# Nicolas Barcet <nicolas.barcet@ubuntu.com>, 2008.
#
#: screen-profiles:297
#: screen-profiles:300
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: 1.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2009-03-31 17:36-0500\n"
"POT-Creation-Date: 2009-04-03 11:01-0500\n"
"PO-Revision-Date: 2008-12-17 23:42+0100\n"
"Last-Translator: Nicolas Barcet <nicolas.barcet@ubuntu.com>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@ -57,7 +57,7 @@ msgstr ""
msgid "Exit"
msgstr ""
#: screen-profiles:87 screen-profiles:463
#: screen-profiles:87 screen-profiles:466
msgid " Screen Profiles Configuration Menu"
msgstr ""
@ -66,14 +66,14 @@ msgid "Okay"
msgstr ""
#: screen-profiles:98 screen-profiles:134 screen-profiles:150
#: screen-profiles:185 screen-profiles:304 screen-profiles:346
#: screen-profiles:424
#: screen-profiles:185 screen-profiles:307 screen-profiles:349
#: screen-profiles:427
msgid "Cancel"
msgstr ""
#: screen-profiles:116 screen-profiles:143 screen-profiles:157
#: screen-profiles:317 screen-profiles:371 screen-profiles:379
#: screen-profiles:452
#: screen-profiles:320 screen-profiles:374 screen-profiles:382
#: screen-profiles:455
msgid "Menu"
msgstr ""
@ -82,7 +82,7 @@ msgid "Screen Profiles Help"
msgstr ""
#: screen-profiles:134 screen-profiles:150 screen-profiles:185
#: screen-profiles:304 screen-profiles:346 screen-profiles:424
#: screen-profiles:307 screen-profiles:349 screen-profiles:427
msgid "Apply"
msgstr ""
@ -90,8 +90,8 @@ msgstr ""
msgid "Which profile would you like to use?"
msgstr ""
#: screen-profiles:142 screen-profiles:156 screen-profiles:316
#: screen-profiles:378 screen-profiles:450
#: screen-profiles:142 screen-profiles:156 screen-profiles:319
#: screen-profiles:381 screen-profiles:453
msgid "Message"
msgstr ""
@ -119,35 +119,35 @@ msgstr ""
msgid "Create new window(s):"
msgstr ""
#: screen-profiles:305
#: screen-profiles:308
msgid "Toggle status notifications:"
msgstr ""
#: screen-profiles:338
#: screen-profiles:341
msgid "Windows:"
msgstr ""
#: screen-profiles:348
#: screen-profiles:351
msgid "Select window(s) to create by default:"
msgstr ""
#: screen-profiles:368
#: screen-profiles:371
msgid "Screen will be launched automatically next time you login."
msgstr ""
#: screen-profiles:376
#: screen-profiles:379
msgid "Screen will not be used next time you login."
msgstr ""
#: screen-profiles:423
#: screen-profiles:426
msgid "Escape key: ctrl-"
msgstr ""
#: screen-profiles:426
#: screen-profiles:429
msgid "Change escape sequence:"
msgstr ""
#: screen-profiles:464
#: screen-profiles:467
msgid "<Tab>/<Alt-Tab> between elements | <Return> Validates"
msgstr ""

View file

@ -3,13 +3,13 @@
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#: screen-profiles:297
#: screen-profiles:300
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2009-03-31 17:36-0500\n"
"POT-Creation-Date: 2009-04-03 11:01-0500\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@ -57,7 +57,7 @@ msgstr ""
msgid "Exit"
msgstr ""
#: screen-profiles:87 screen-profiles:463
#: screen-profiles:87 screen-profiles:466
msgid " Screen Profiles Configuration Menu"
msgstr ""
@ -66,14 +66,14 @@ msgid "Okay"
msgstr ""
#: screen-profiles:98 screen-profiles:134 screen-profiles:150
#: screen-profiles:185 screen-profiles:304 screen-profiles:346
#: screen-profiles:424
#: screen-profiles:185 screen-profiles:307 screen-profiles:349
#: screen-profiles:427
msgid "Cancel"
msgstr ""
#: screen-profiles:116 screen-profiles:143 screen-profiles:157
#: screen-profiles:317 screen-profiles:371 screen-profiles:379
#: screen-profiles:452
#: screen-profiles:320 screen-profiles:374 screen-profiles:382
#: screen-profiles:455
msgid "Menu"
msgstr ""
@ -82,7 +82,7 @@ msgid "Screen Profiles Help"
msgstr ""
#: screen-profiles:134 screen-profiles:150 screen-profiles:185
#: screen-profiles:304 screen-profiles:346 screen-profiles:424
#: screen-profiles:307 screen-profiles:349 screen-profiles:427
msgid "Apply"
msgstr ""
@ -90,8 +90,8 @@ msgstr ""
msgid "Which profile would you like to use?"
msgstr ""
#: screen-profiles:142 screen-profiles:156 screen-profiles:316
#: screen-profiles:378 screen-profiles:450
#: screen-profiles:142 screen-profiles:156 screen-profiles:319
#: screen-profiles:381 screen-profiles:453
msgid "Message"
msgstr ""
@ -119,34 +119,34 @@ msgstr ""
msgid "Create new window(s):"
msgstr ""
#: screen-profiles:305
#: screen-profiles:308
msgid "Toggle status notifications:"
msgstr ""
#: screen-profiles:338
#: screen-profiles:341
msgid "Windows:"
msgstr ""
#: screen-profiles:348
#: screen-profiles:351
msgid "Select window(s) to create by default:"
msgstr ""
#: screen-profiles:368
#: screen-profiles:371
msgid "Screen will be launched automatically next time you login."
msgstr ""
#: screen-profiles:376
#: screen-profiles:379
msgid "Screen will not be used next time you login."
msgstr ""
#: screen-profiles:423
#: screen-profiles:426
msgid "Escape key: ctrl-"
msgstr ""
#: screen-profiles:426
#: screen-profiles:429
msgid "Change escape sequence:"
msgstr ""
#: screen-profiles:464
#: screen-profiles:467
msgid "<Tab>/<Alt-Tab> between elements | <Return> Validates"
msgstr ""

View file

@ -40,6 +40,9 @@ backtick 109 3600 3600 /var/lib/screen-profiles/hostname
backtick 110 86400 86400 /var/lib/screen-profiles/whoami
backtick 111 86400 86400 /var/lib/screen-profiles/menu
backtick 112 86400 86400 /var/lib/screen-profiles/arch
backtick 113 30 30 /var/lib/screen-profiles/battery
backtick 114 2 2 /var/lib/screen-profiles/users
backtick 115 60 60 /var/lib/screen-profiles/uptime
hardstatus alwayslastline

View file

@ -26,7 +26,7 @@ source /usr/share/screen-profiles/profiles/common
caption always "%{kW}%?%-Lw%?%{bw}%n*%f %t%?(%u)%?%{kW}%?%+Lw%? %= %{=b Wk}%110`%109` %{= kw}%111`"
# Status string, last line
hardstatus string '%99`%{=b Wk} %100` %{= Wk}%112` %= %{=b bW}%102`%{= Wk} %{=b rW}%101`%{= Wk} %{= Wg}%108`%{= Wk} %{= Yk}%106`%{= Wk} %{= Wk}%104`%{=b cW}%103`%{= Wk} %{=b gW}%105`%107`%{= Wk} %Y-%m-%d %0c:%s'
hardstatus string '%99`%{=b Wk} %100` %{= Wk}%112` %= %113`%{=b Wk}%114`%{=b Wk}%115`%{=b Wk} %{=b bW}%102`%{= Wk} %{=b rW}%101`%{= Wk} %{= Wg}%108`%{= Wk} %{= Yk}%106`%{= Wk} %{= Wk}%104`%{=b cW}%103`%{= Wk} %{=b gW}%105`%107`%{= Wk} %Y-%m-%d %0c:%s'
# NOTE: Older version of screen have an arbitrary limit of only being able
# to change colors 16 times in this 'hardstatus string'.

View file

@ -247,6 +247,7 @@ def readwindows():
def readstatus():
status={}
status["arch"]=0
status["battery"]=0
status["cpu-count"]=1
status["cpu-freq"]=1
status["ec2-cost"]=0
@ -259,6 +260,8 @@ def readstatus():
status["reboot-required"]=1
status["release"]=1
status["updates-available"]=1
status["users"]=0
status["uptime"]=0
status["whoami"]=0
if os.path.exists(HOME+'/.screen-profiles/status'):
f=open(HOME+'/.screen-profiles/status', 'r')