diff options
author | H. P. <harald.p.@xmart.de> | 2018-11-01 13:30:58 +0100 |
---|---|---|
committer | H. P. <harald.p.@xmart.de> | 2018-11-01 13:30:58 +0100 |
commit | 0632591996893fe136a1f2fe44d9b9f404f41f3e (patch) | |
tree | 7340edbe7c212da3db45a83219147143a3268c8d /localfs/usr/local/bin | |
download | fedora-laptop-0632591996893fe136a1f2fe44d9b9f404f41f3e.tar.bz2 |
Initial commit
Diffstat (limited to 'localfs/usr/local/bin')
-rwxr-xr-x | localfs/usr/local/bin/batman | 41 | ||||
-rwxr-xr-x | localfs/usr/local/bin/virtmc | 22 | ||||
l--------- | localfs/usr/local/bin/virtme | 1 | ||||
l--------- | localfs/usr/local/bin/virtmp | 1 |
4 files changed, 65 insertions, 0 deletions
diff --git a/localfs/usr/local/bin/batman b/localfs/usr/local/bin/batman new file mode 100755 index 0000000..bfa00c0 --- /dev/null +++ b/localfs/usr/local/bin/batman @@ -0,0 +1,41 @@ +#!/bin/sh + +declare -x VOERBOOS +export RETVAL=0 +export BATVAL="$(echo "scale=0;$(cat /sys/class/power_supply/BAT0/charge_now)*100/$(cat /sys/class/power_supply/BAT0/charge_full)"|bc -l)" +export BATSTATE="$(cat /sys/class/power_supply/BAT0/status)" +function batmobile { + if [ "$BATVAL" -le 5 ];then + case "$BATSTATE" in + "Charging") + MSG="Battery charged at $BATVAL% with status \"$BATSTATE\", no shutdown." + [ ! -z "$VOERBOOS" ]&&[ "$VOERBOOS" -eq 1 ]&&echo "$MSG"||true + logger -p"info" -t"batman" "Battery charged at $BATVAL% with status \"$BATSTATE\", no shutdown."||RETVAL=$(("$RETVAL"+$?)) + ;; + *) + MSG="Battery charged at $BATVAL%, powering down." + [ ! -z "$VOERBOOS" ]&&[ "$VOERBOOS" -eq 1 ]&&echo "$MSG"||true + logger -pwarn -t"batman" "$MSG"||RETVAL=$(("$RETVAL"+$?)) + sudo shutdown -P +2 "$MSG"||RETVAL=$(("$RETVAL"+$?)) + ;; + esac + else + MSG="Battery charged at $BATVAL%, no shutdown." + [ ! -z "$VOERBOOS" ]&&[ "$VOERBOOS" -eq 1 ]&&echo "$MSG"||logger -p"info" -t"batman" "$MSG"||RETVAL=$(("$RETVAL"+$?)) + fi +} +function batarang { + MSG="$BATVAL% ($BATSTATE)";echo "$MSG"; +} + +while getopts :vnp SHOPT;do + case "$SHOPT" in + v)export VOERBOOS=1;; + p)batmobile;; + ""|n)batarang;; + *)echo "Not supported option: -""${OPTARG}" >&2;RETVAL=$(($RETVAL+1)) >&2;WRONGOPT=1;; + esac +done +shift $(( $OPTIND - 1 )) +[ ! -z "$WRONGOPT" ]&&[ "$WRONGOPT" -eq 1 ]&&exit 1||true +exit "$RETVAL" diff --git a/localfs/usr/local/bin/virtmc b/localfs/usr/local/bin/virtmc new file mode 100755 index 0000000..5fee1bb --- /dev/null +++ b/localfs/usr/local/bin/virtmc @@ -0,0 +1,22 @@ +#!/bin/bash + +[ -z "$LIBVIRT_DEFAULT_URI" ]&&CONNURI="qemu:///system"||CONNURI="$LIBVIRT_DEFAULT_URI" +[ -z "$1" ]&&echo "Viciously refusing to connect to the KVM console of the zero pointer." >&2&&exit 1 + +virtmhelp() { + echo -e "USAGE:\tvirtmc|virtme|virtmp" + echo + ( + echo ";virtmc:;Shows the domain's console screen" + echo ";virtme:;Shows the domain editor without going to the console screen" + echo ";virtmp:;Shows the domain's performance" + )|column -s\; -t --table-right 2 +} +[ "$1" == "-h" ]&&virtmhelp&&exit 0 + +case "$(basename $0)" in + virtmc) virt-manager -c "$CONNURI" --show-domain-console "$1";; + virtme) virt-manager -c "$CONNURI" --show-domain-editor "$1";; + virtmp) virt-manager -c "$CONNURI" --show-domain-performance "$1";; + *) echo "Fatal exception: do not simply symlink stuff without knowing what you do!" >&2;exit 1;; +esac diff --git a/localfs/usr/local/bin/virtme b/localfs/usr/local/bin/virtme new file mode 120000 index 0000000..3f2582b --- /dev/null +++ b/localfs/usr/local/bin/virtme @@ -0,0 +1 @@ +virtmc
\ No newline at end of file diff --git a/localfs/usr/local/bin/virtmp b/localfs/usr/local/bin/virtmp new file mode 120000 index 0000000..3f2582b --- /dev/null +++ b/localfs/usr/local/bin/virtmp @@ -0,0 +1 @@ +virtmc
\ No newline at end of file |