screen-profiles-status: new, central script for all status actions;

allows us to centralize some things, like enable/disable checking
and process nice-ness
-Dustin Kirkland <kirkland@ubuntu.com>Fri, 03 Apr 2009 13:07:57 -0700
This commit is contained in:
Dustin Kirkland 2009-04-03 13:14:11 -07:00
commit 8002b813fd
2 changed files with 48 additions and 1 deletions

5
debian/changelog vendored
View file

@ -10,13 +10,16 @@ screen-profiles (1.43) unreleased; urgency=low
items that require an action (reboot, updates)
* profiles/profile.skel: move reboot-required and updates-available to
the early part of the status string, since these require action
* screen-profiles-status: new, central script for all status actions;
allows us to centralize some things, like enable/disable checking
and process nice-ness
[ 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 12:42:53 -0500
-- Dustin Kirkland <kirkland@ubuntu.com> Fri, 03 Apr 2009 13:07:57 -0700
screen-profiles (1.42-0ubuntu1) jaunty; urgency=low

44
screen-profiles-status Executable file
View file

@ -0,0 +1,44 @@
#!/bin/sh -e
#
# select-screen-profile
# Copyright (C) 2008 Canonical Ltd.
#
# Authors: Dustin Kirkland <kirkland@canonical.com>
# Nick Barcet <nick.barcet@ubuntu.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/>.
# Let's try to be really "nice" about gathering status:
renice 10 $$ >/dev/null 2>&1 || true
ionice -c3 -p $$ >/dev/null 2>&1 || true
DIR="/var/lib/screen-profiles"
P="$1"
case "$P" in
# default = on, user must override to turn off
cpu-count|cpu-freq|load-average|logo|mem-available|mem-used|menu|reboot-required|release|updates-available)
grep -qs "^$P=0$" "$HOME/.screen-profiles/status" && exit 0
;;
# default = off, user must override to turn on
arch|battery|ec2-cost|hostname|processes|uptime|users|whoami)
grep -qs "^$P=1$" "$HOME/.screen-profiles/status" || exit 0
;;
*)
exit 1
;;
esac
if [ -f "$DIR"/"$P" -a -x "$DIR"/"$P" ]; then
exec "$DIR"/"$P"
fi