scripts

various script and utils
git clone git://z3bra.org/scripts
Log | Files | Refs

commit ce9ab30db7657ff32b273bd760c249256d10bbc4
parent f04b62b7eea101104e3352e7047e166ed4947784
Author: z3bra <willy@mailoo.org>
Date:   Thu Apr  3 10:40:36 +0200

Removed .sh extension

Diffstat:
battery | 55+++++++++++++++++++++++++++++++++++++++++++++++++++++++
battery.sh | 55-------------------------------------------------------
dualhead | 13+++++++++++++
dualhead.sh | 13-------------
gamma | 24++++++++++++++++++++++++
gamma.sh | 24------------------------
statusline.sh | 29-----------------------------
7 files changed, 92 insertions(+), 121 deletions(-)
diff --git a/battery b/battery @@ -0,0 +1,55 @@ +#!/bin/sh +# +# beep once per level. does not beep when charging + +# get battery level and status (charging or not) +BATC=`cat /sys/class/power_supply/BAT1/capacity` +BATS=`cat /sys/class/power_supply/BAT1/status` + +# Run this if sound is enabled +sbell () { + IFS=' %' read level state <<< `~/bin/volume` + + ~/bin/volume unmute + ~/bin/volume '80%' + + beep -f 1000 -l 200 -D 50 + + case $state in + on) ~/bin/volume unmute;; + off) ~/bin/volume mute;; + esac + + # reset volume to its previous state + ~/bin/volume "${level}%" +} + +# and this in case of no sound enabled +vbell () { + $HOME/bin/popup "%{F#d43f10}battery $BATC%%" +} + +usage () { + echo "usage: `basename $0` [<low> <critical> <dead>]" + exit 1 +} + +level () { + echo "$BATC%" + exit 0 +} + +# If no argurments, return battery level +test "$#" -eq 0 && level + +# if less than 3 args, learn how to use, dumb +test "$#" -lt 3 && usage + +# if battery is charging, do not alert user +test "$BATS" == "Charging" && exit + +test $BATC -lt $1 && sbell # one bip for level <low> +test $BATC -lt $2 && sbell # two bip for level <critical> +test $BATC -lt $3 && sbell # battery is <dead>, bip 3 times + +test $BATC -lt $1 && vbell # popup a notification under <low> level diff --git a/battery.sh b/battery.sh @@ -1,55 +0,0 @@ -#!/bin/sh -# -# beep once per level. does not beep when charging - -# get battery level and status (charging or not) -BATC=`cat /sys/class/power_supply/BAT1/capacity` -BATS=`cat /sys/class/power_supply/BAT1/status` - -# Run this if sound is enabled -sbell () { - IFS=' %' read level state <<< `~/bin/volume` - - ~/bin/volume unmute - ~/bin/volume '80%' - - beep -f 1000 -l 200 -D 50 - - case $state in - on) ~/bin/volume unmute;; - off) ~/bin/volume mute;; - esac - - # reset volume to its previous state - ~/bin/volume "${level}%" -} - -# and this in case of no sound enabled -vbell () { - $HOME/bin/popup "%{F#d43f10}battery $BATC%%" -} - -usage () { - echo "usage: `basename $0` [<low> <critical> <dead>]" - exit 1 -} - -level () { - echo "$BATC%" - exit 0 -} - -# If no argurments, return battery level -test "$#" -eq 0 && level - -# if less than 3 args, learn how to use, dumb -test "$#" -lt 3 && usage - -# if battery is charging, do not alert user -test "$BATS" == "Charging" && exit - -test $BATC -lt $1 && sbell # one bip for level <low> -test $BATC -lt $2 && sbell # two bip for level <critical> -test $BATC -lt $3 && sbell # battery is <dead>, bip 3 times - -test $BATC -lt $1 && vbell # popup a notification under <low> level diff --git a/dualhead b/dualhead @@ -0,0 +1,13 @@ +#!/bin/sh + +case "$1" in + "left") + xrandr --output VGA1 --primary --auto --output LVDS1 --auto --right-of VGA1;; + "right") + xrandr --output VGA1 --primary --auto --output LVDS1 --auto --left-of VGA1;; + "dup") + xrandr --output VGA1 --same-as LVDS1 --output LVDS1 --primary;; + "only") + xrandr --output VGA1 --primary --auto --output LVDS1 --off;; + *) echo `basename $0` '{left|right|same|only}';; +esac diff --git a/dualhead.sh b/dualhead.sh @@ -1,13 +0,0 @@ -#!/bin/sh - -case "$1" in - "left") - xrandr --output VGA1 --primary --auto --output LVDS1 --auto --right-of VGA1;; - "right") - xrandr --output VGA1 --primary --auto --output LVDS1 --auto --left-of VGA1;; - "dup") - xrandr --output VGA1 --same-as LVDS1 --output LVDS1 --primary;; - "only") - xrandr --output VGA1 --primary --auto --output LVDS1 --off;; - *) echo `basename $0` '{left|right|same|only}';; -esac diff --git a/gamma b/gamma @@ -0,0 +1,24 @@ +#!/bin/sh + +usage () { + echo "usage: `basename $0` <get|up|down|reset> [value]" +} + +test "$#" -lt 1 && usage && exit +test -n "$2" && amount=$2 || amount=0.1 + +gamma=`grep RedGamma ~/.nvidia| cut -d= -f2` +old=$gamma + +case $1 in + get) echo $gamma; exit ;; + up) gamma=`bc <<< "$gamma + $amount"` ;; + down) gamma=`bc <<< "$gamma - $amount"` ;; + reset)gamma="1.000000" ;; + *) usage && exit ;; +esac + +echo "$old -> $gamma" + +nvidia-settings -a [DPY:DVI-I-0]/Gamma=$gamma >/dev/null +sed -i "/Gamma/s/$old/$gamma/" ~/.nvidia diff --git a/gamma.sh b/gamma.sh @@ -1,24 +0,0 @@ -#!/bin/sh - -usage () { - echo "usage: `basename $0` <get|up|down|reset> [value]" -} - -test "$#" -lt 1 && usage && exit -test -n "$2" && amount=$2 || amount=0.1 - -gamma=`grep RedGamma ~/.nvidia| cut -d= -f2` -old=$gamma - -case $1 in - get) echo $gamma; exit ;; - up) gamma=`bc <<< "$gamma + $amount"` ;; - down) gamma=`bc <<< "$gamma - $amount"` ;; - reset)gamma="1.000000" ;; - *) usage && exit ;; -esac - -echo "$old -> $gamma" - -nvidia-settings -a [DPY:DVI-I-0]/Gamma=$gamma >/dev/null -sed -i "/Gamma/s/$old/$gamma/" ~/.nvidia diff --git a/statusline.sh b/statusline.sh @@ -1,29 +0,0 @@ -#!/bin/bash -# -# status line for tmux. -# prints out a line formatted for tmux status. - - -w='#[fg=yellow,bold]' -B='#[fg=black,bold]' - -SEP="$w»$B" -# SEP="$w>$B>$B" - - -TEMP=$(acpi -t | awk '{print $4}') -LOAD=$(uptime | sed 's/^.*average: \([^ ]*\),.*$/\1/') -TIME=$(date "+%H:%M") -DATE=$(date "+%a%d") - -ramused() { - ramtotal=$(free -m| sed -n '2p'| awk '{print $2}') - ramused=$(free -m| sed -n '3p'| awk '{print $3}') - - ram_perc=$(( 100*$ramused/$ramtotal )) - echo $ram_perc -} - - -echo "$B$(ramused)% $SEP $LOAD $SEP $TEMP°C $SEP $DATE $w$TIME" -