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..
|
|
|
|
|
2014-09-02 09:32:36 +00:00
|
|
|
SNU=1
|
|
|
|
VGA=VGA$SNU
|
|
|
|
LVDS=LVDS$SNU
|
|
|
|
|
2013-06-11 20:39:53 +00:00
|
|
|
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")
|
|
|
|
case $2 in
|
|
|
|
"toggle")
|
|
|
|
mpc toggle
|
|
|
|
;;
|
2014-03-24 20:37:32 +00:00
|
|
|
"pause")
|
|
|
|
mpc pause
|
|
|
|
;;
|
2013-12-02 22:37:14 +00:00
|
|
|
"next")
|
|
|
|
mpc next
|
|
|
|
;;
|
|
|
|
"prev")
|
|
|
|
mpc prev
|
|
|
|
;;
|
|
|
|
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
|
|
|
|
;;
|
|
|
|
|
2013-12-02 22:37:14 +00:00
|
|
|
|
2013-06-11 20:39:53 +00:00
|
|
|
"monitor")
|
|
|
|
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 \
|
|
|
|
--right-of $LVDS
|
2013-09-29 15:36:18 +00:00
|
|
|
;;
|
2013-12-18 22:08:34 +00:00
|
|
|
"programming")
|
2014-09-02 09:32:36 +00:00
|
|
|
xrandr --output $VGA --auto --rotate left \
|
|
|
|
--output $LVDS --off
|
2013-12-18 22:08:34 +00:00
|
|
|
;;
|
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")
|
|
|
|
xset dpms force off
|
2014-09-23 18:50:19 +00:00
|
|
|
sleep 1
|
2013-06-14 17:13:19 +00:00
|
|
|
;;
|
2013-06-11 20:39:53 +00:00
|
|
|
esac
|
|
|
|
$0 wallpaper
|
|
|
|
;;
|
|
|
|
|
|
|
|
"refresh")
|
2013-07-07 13:06:43 +00:00
|
|
|
DATE=`date +"%A %d, %Hh%M - %s"`
|
2013-06-25 23:22:52 +00:00
|
|
|
BATT_PCT=$(acpi -b | cut -d, -f2 | cut -d" " -f2)
|
|
|
|
BATT_TIME=$(acpi -b | cut -d, -f3 | cut -d" " -f2)
|
|
|
|
#BATT=$( acpi -b | sed 's/.*[charg.|], \([0-9]*\)%.*/\1/gi' )
|
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`
|
2013-06-11 21:26:08 +00:00
|
|
|
|
2014-04-01 20:00:13 +00:00
|
|
|
if [ -n `mpc | grep paused` ]; then
|
|
|
|
STAT=">"
|
|
|
|
else
|
|
|
|
STAT="||"
|
|
|
|
fi;
|
|
|
|
|
2013-07-18 15:29:28 +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`
|
2013-08-06 10:18:27 +00:00
|
|
|
BEAT_TIME=`beat -v`
|
2013-07-18 15:29:28 +00:00
|
|
|
|
2014-04-01 20:00:13 +00:00
|
|
|
xsetroot -name "Vol $VOLUME :: [$STAT $SONG] :: $MEMFT Mb Free :: Bat $BATT_PCT $BATT_TIME :: $DATE (@$BEAT_TIME)" || true
|
2014-01-20 09:55:57 +00:00
|
|
|
$0 conf-ifaces
|
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")
|
|
|
|
ifconfig eth0 | grep netmask > /dev/null
|
|
|
|
if [ $? -eq 0 ]; then
|
|
|
|
sudo ifconfig wlan0 down
|
|
|
|
else
|
|
|
|
sudo ifconfig wlan0 up
|
|
|
|
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")
|
|
|
|
sudo systemctl start cups
|
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
|