dotfiles/Utils/octopus.sh

163 lines
3.1 KiB
Bash
Raw Normal View History

2013-06-11 20:39:53 +00:00
#!/bin/bash
2013-10-15 18:59:15 +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
;;
esac
$0 refresh
;;
2013-12-02 22:37:14 +00:00
"audio")
case $2 in
"toggle")
mpc toggle
;;
"next")
mpc next
;;
"prev")
mpc prev
;;
esac
$0 refresh
;;
2013-06-11 20:39:53 +00:00
"monitor")
case $2 in
"extern")
xrandr --output LVDS2 --off \
--output VGA2 --auto --rotate normal
2013-06-11 20:39:53 +00:00
;;
"laptop")
xrandr --output LVDS2 --auto --rotate normal \
--output VGA2 --off
2013-06-11 20:39:53 +00:00
;;
"dual")
xrandr --output LVDS2 --auto --rotate normal \
--output VGA2 --auto --rotate normal \
--right-of LVDS2
2013-09-29 15:36:18 +00:00
;;
"programming")
xrandr --output VGA2 --auto --rotate left \
--output LVDS2 --off
;;
2013-09-30 07:49:46 +00:00
"pdfpc")
xrandr --output LVDS2 --auto --rotate normal \
--output VGA2 --auto --rotate normal \
--left-of LVDS2
2013-09-30 07:49:46 +00:00
;;
2013-09-29 15:36:18 +00:00
"clone")
xrandr --output LVDS2 --auto \
--output VGA2 --auto --same-as LVDS2
2013-06-11 20:39:53 +00:00
;;
2013-06-14 17:13:19 +00:00
"off")
xset dpms force off
;;
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"`
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-01-02 22:55:00 +00:00
VOLUME=`/usr/bin/amixer get Master | grep "%" | cut -d' ' -f6`
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
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-12-28 02:21:07 +00:00
xsetroot -name "Vol $VOLUME :: [$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")
xrandr | grep "VGA2 disconnected" > /dev/null
2014-01-20 09:55:57 +00:00
if [ $? -eq 0 ]; then
2013-06-11 21:26:08 +00:00
$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 &
2013-06-14 17:13:19 +00:00
systemctl suspend
2013-08-22 14:26:45 +00:00
;;
"lock")
2014-01-20 09:55:57 +00:00
slock &
2014-01-16 11:16:46 +00:00
xset dpms force 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