dotfiles/Utils/octopus.sh

214 lines
4 KiB
Bash
Raw Normal View History

2013-06-11 20:39:53 +00:00
#!/bin/bash
2014-03-09 21:35:57 +00:00
#set -x
2013-06-11 21:26:08 +00:00
#OCTOPUS=~/Programmation/Utils/octopus.sh
2013-06-11 20:39:53 +00:00
#This octopus handles all the actions like volume up, refresh status bar, etc..
if [ $# -lt 1 ]
then
2013-07-01 20:56:32 +00:00
echo "Usage : $0 [vol up|vol down|refresh|monitor extern|monitor laptop|monitor dual...]"
2013-06-11 20:39:53 +00:00
exit
fi
case $1 in
"vol"|"volume")
case $2 in
"up")
amixer -q set Master 5%+ unmute
;;
"down")
amixer -q set Master 5%- unmute
;;
"mute")
2013-06-11 21:26:08 +00:00
amixer -q set Master toggle
2013-06-11 20:39:53 +00:00
;;
2014-03-09 21:35:57 +00:00
"max")
amixer -q set Master 100% unmute
;;
2013-06-11 20:39:53 +00:00
esac
$0 refresh
;;
2013-12-02 22:37:14 +00:00
"audio")
#so that '$0 refresh' will be up2date (song didn't change after)
mpc_cmd='mpc --wait'
2013-12-02 22:37:14 +00:00
case $2 in
"toggle")
$mpc_cmd toggle
2013-12-02 22:37:14 +00:00
;;
2014-03-24 20:37:32 +00:00
"pause")
$mpc_cmd pause
2014-03-24 20:37:32 +00:00
;;
2013-12-02 22:37:14 +00:00
"next")
$mpc_cmd next
2013-12-02 22:37:14 +00:00
;;
"prev")
$mpc_cmd prev
2013-12-02 22:37:14 +00:00
;;
esac
$0 refresh
;;
2014-03-09 21:35:57 +00:00
"play")
case $2 in
"inception")
2014-03-24 20:37:32 +00:00
$0 audio pause
2014-03-09 21:35:57 +00:00
$0 vol max
NN=`dirname $0`
mplayer $NN/audio/inception.mp3
;;
esac
;;
2015-03-01 17:44:25 +00:00
"leds")
case $2 in
"power")
case $3 in
"off")
echo 0 | sudo tee /sys/devices/platform/thinkpad_acpi/leds/tpacpi::power/brightness
;;
esac
;;
esac
;;
2013-12-02 22:37:14 +00:00
2013-06-11 20:39:53 +00:00
"monitor")
2015-12-04 18:22:19 +00:00
SNU=`xrandr | grep VGA | cut -d' ' -f1 | cut -c4`
VGA=VGA$SNU
LVDS=LVDS$SNU
2013-06-11 20:39:53 +00:00
case $2 in
"extern")
2014-09-02 09:32:36 +00:00
xrandr --output $LVDS --off \
--output $VGA --auto --rotate normal
2013-06-11 20:39:53 +00:00
;;
"laptop")
2014-09-02 09:32:36 +00:00
xrandr --output $LVDS --auto --rotate normal \
--output $VGA --off
2013-06-11 20:39:53 +00:00
;;
"dual")
2014-09-02 09:32:36 +00:00
xrandr --output $LVDS --auto --rotate normal \
--output $VGA --auto --rotate normal \
2016-09-15 20:15:55 +00:00
--right-of $LVDS
2013-09-29 15:36:18 +00:00
;;
2016-02-01 09:21:14 +00:00
"CV")
2016-07-22 12:53:14 +00:00
xrandr --output $LVDS --auto --rotate normal \
--output $VGA --auto --rotate normal \
--right-of $LVDS
;;
"dualCV")
2016-02-01 09:21:14 +00:00
xrandr --output $LVDS --auto --rotate normal \
--output $VGA --auto --rotate left --right-of $LVDS
;;
"programming")
2014-09-02 09:32:36 +00:00
xrandr --output $VGA --auto --rotate left \
--output $LVDS --off
;;
2013-09-30 07:49:46 +00:00
"pdfpc")
2014-09-02 09:32:36 +00:00
xrandr --output $LVDS --auto --rotate normal \
--output $VGA --auto --rotate normal \
--left-of $LVDS
2013-09-30 07:49:46 +00:00
;;
2013-09-29 15:36:18 +00:00
"clone")
2014-09-02 09:32:36 +00:00
xrandr --output $LVDS --auto \
--output $VGA --auto --same-as $LVDS
2013-06-11 20:39:53 +00:00
;;
2013-06-14 17:13:19 +00:00
"off")
2015-02-24 20:50:11 +00:00
sleep 0.1
2013-06-14 17:13:19 +00:00
xset dpms force off
;;
2013-06-11 20:39:53 +00:00
esac
$0 wallpaper
;;
"refresh")
DATE=`date +"%a %e %Hh%M"`
BATT_PCT=$(acpi -b | cut -d, -f2 | cut -d" " -f2)
BATT_TIME=$(acpi -b | cut -d, -f3 | cut -d" " -f2)
2014-06-30 17:57:19 +00:00
VOLUME=`/usr/bin/amixer get Master | grep "%" | cut -d' ' -f7 | head -n1`
2013-11-01 15:45:53 +00:00
## VOLUME=`amixer get Master | grep '\[' | cut -d' ' -f6`
2013-12-02 22:37:14 +00:00
SONG=`mpc | head -n 1 | cut -d. -f1`
maxSL=22
if [ ${#SONG} -gt $maxSL ]; then
SONG=`echo $SONG | cut -c1-$maxSL`.
fi
2015-03-01 17:44:25 +00:00
############ BTC=`BTC_stats.sh`
2013-06-11 21:26:08 +00:00
MEMFREE=`awk '/MemFree/ {printf( "%.0f", $2 / 1024 )}' /proc/meminfo`
MEMCACHED=`awk '/Cached/ {printf( "%.0f", $2 / 10240 )}' /proc/meminfo`
MEMFT=`echo "$MEMFREE + $MEMCACHED" | bc`
2015-03-01 17:44:25 +00:00
xsetroot -name "$VOLUME [$STAT $SONG] :: Bat $BATT_PCT $BATT_TIME :: $DATE" || true
2014-01-20 09:55:57 +00:00
$0 conf-ifaces
2015-03-01 17:44:25 +00:00
$0 leds power off
2013-06-11 20:39:53 +00:00
;;
"wallpaper")
2013-12-28 02:21:07 +00:00
~/Pictures/wallpapers/chooseWP.sh || true &
2013-06-11 20:39:53 +00:00
;;
2014-01-20 09:55:57 +00:00
"conf-ifaces")
2015-12-04 18:22:19 +00:00
if lsusb | grep -q 'M105 Optical Mouse'; then
sudo ifconfig eth0 up
sudo ifconfig wlan0 down
2014-01-20 09:55:57 +00:00
else
2015-12-04 18:22:19 +00:00
sudo ifconfig wlan0 up
2014-01-20 09:55:57 +00:00
fi
;;
2013-09-29 15:59:30 +00:00
"reset-screen")
$0 init-all
;;
2013-06-11 21:26:08 +00:00
"init-all")
2014-09-02 09:32:36 +00:00
xrandr | grep "$VGA disconnected" > /dev/null
if [ $? -eq 0 ]; then
$0 monitor laptop
else
$0 monitor extern
fi
2013-10-15 18:59:15 +00:00
2013-12-07 14:42:02 +00:00
sudo killall dhcpcd
2013-10-15 18:59:15 +00:00
$0 init-wifi &
$0 init-ethernet &
2013-10-14 09:22:08 +00:00
$0 init-mouse
2013-06-11 21:26:08 +00:00
$0 wallpaper
2013-06-14 17:13:19 +00:00
;;
2013-10-14 09:22:08 +00:00
"init-mouse")
2013-12-28 02:21:07 +00:00
sudo tpkbdctl -s255 || true
2013-10-14 09:22:08 +00:00
;;
"init-wifi")
2013-10-15 18:59:15 +00:00
sudo killall wpa_supplicant
2013-12-07 14:42:02 +00:00
sudo wpa_supplicant -B -iwlan0 -c/etc/wpa_supplicant/wpa_supplicant.conf &
sleep 1
sudo ifconfig wlan0 up
sudo dhcpcd wlan0 -b -m 1000 -p -t 0 &
2013-10-14 09:22:08 +00:00
;;
"init-ethernet")
sudo ifconfig eth0 up &
2013-12-07 14:42:02 +00:00
sudo dhcpcd eth0 -b -m 10 -p -t 0 &
2013-10-14 09:22:08 +00:00
;;
2013-06-14 17:13:19 +00:00
"suspend")
2014-01-20 09:55:57 +00:00
slock &
2014-08-04 21:19:01 +00:00
systemctl suspend -i
2013-08-22 14:26:45 +00:00
;;
"lock")
2014-01-20 09:55:57 +00:00
slock &
2014-09-23 18:50:19 +00:00
$0 monitor off
2014-01-20 09:55:57 +00:00
;;
"print")
2014-11-11 17:57:48 +00:00
sudo systemctl start org.cups.cupsd #fucking name changes…
2013-08-22 14:26:45 +00:00
;;
2013-06-11 21:26:08 +00:00
2013-06-11 20:39:53 +00:00
esac
2013-06-11 21:26:08 +00:00
# vim: ts=4