149 lines
2.9 KiB
Bash
Executable file
149 lines
2.9 KiB
Bash
Executable file
#!/bin/bash
|
|
set -x
|
|
#OCTOPUS=~/Programmation/Utils/octopus.sh
|
|
#This octopus handles all the actions like volume up, refresh status bar, etc..
|
|
|
|
if [ $# -lt 1 ]
|
|
then
|
|
echo "Usage : $0 [vol up|vol down|refresh|monitor extern|monitor laptop|monitor dual...]"
|
|
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")
|
|
amixer -q set Master toggle
|
|
;;
|
|
esac
|
|
$0 refresh
|
|
;;
|
|
|
|
"audio")
|
|
case $2 in
|
|
"toggle")
|
|
mpc toggle
|
|
;;
|
|
"next")
|
|
mpc next
|
|
;;
|
|
"prev")
|
|
mpc prev
|
|
;;
|
|
esac
|
|
$0 refresh
|
|
;;
|
|
|
|
|
|
"monitor")
|
|
case $2 in
|
|
"extern")
|
|
xrandr --output LVDS2 --off \
|
|
--output VGA2 --auto --rotate normal
|
|
;;
|
|
"laptop")
|
|
xrandr --output LVDS2 --auto --rotate normal \
|
|
--output VGA2 --off
|
|
;;
|
|
"dual")
|
|
xrandr --output LVDS2 --auto --rotate normal \
|
|
--output VGA2 --auto --rotate normal \
|
|
--right-of LVDS2
|
|
;;
|
|
"programming")
|
|
xrandr --output VGA2 --auto --rotate left \
|
|
--output LVDS2 --off
|
|
;;
|
|
"pdfpc")
|
|
xrandr --output LVDS2 --auto --rotate normal \
|
|
--output VGA2 --auto --rotate normal \
|
|
--left-of LVDS2
|
|
;;
|
|
"clone")
|
|
xrandr --output LVDS2 --auto \
|
|
--output VGA2 --auto --same-as LVDS2
|
|
;;
|
|
"off")
|
|
xset dpms force off
|
|
;;
|
|
esac
|
|
$0 wallpaper
|
|
;;
|
|
|
|
"refresh")
|
|
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' )
|
|
VOLUME=`amixer get Master | tail -n 2 | head -n 1 | cut -d' ' -f7`
|
|
## VOLUME=`amixer get Master | grep '\[' | cut -d' ' -f6`
|
|
SONG=`mpc | head -n 1 | cut -d. -f1`
|
|
|
|
MEMFREE=`awk '/MemFree/ {printf( "%.0f", $2 / 1024 )}' /proc/meminfo`
|
|
MEMCACHED=`awk '/Cached/ {printf( "%.0f", $2 / 10240 )}' /proc/meminfo`
|
|
MEMFT=`echo "$MEMFREE + $MEMCACHED" | bc`
|
|
BEAT_TIME=`beat -v`
|
|
|
|
xsetroot -name "Vol $VOLUME :: [$SONG] :: $MEMFT Mb Free :: Bat $BATT_PCT $BATT_TIME :: $DATE (@$BEAT_TIME)"
|
|
;;
|
|
|
|
"wallpaper")
|
|
~/Pictures/wallpapers/chooseWP.sh &
|
|
;;
|
|
|
|
"reset-screen")
|
|
$0 init-all
|
|
;;
|
|
|
|
"init-all")
|
|
xrandr | grep "VGA1 disconnected" > /dev/null
|
|
if [ $? -eq 0 ]
|
|
then
|
|
$0 monitor laptop
|
|
else
|
|
$0 monitor extern
|
|
fi
|
|
|
|
sudo killall dhcpcd
|
|
$0 init-wifi &
|
|
$0 init-ethernet &
|
|
$0 init-mouse
|
|
$0 wallpaper
|
|
;;
|
|
|
|
"init-mouse")
|
|
sudo tpkbdctl -s255
|
|
;;
|
|
|
|
"init-wifi")
|
|
sudo killall wpa_supplicant
|
|
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 &
|
|
;;
|
|
"init-ethernet")
|
|
sudo ifconfig eth0 up &
|
|
sudo dhcpcd eth0 -b -m 10 -p -t 0 &
|
|
;;
|
|
|
|
|
|
"suspend")
|
|
systemctl suspend
|
|
xlock -mode blank
|
|
;;
|
|
|
|
"lock")
|
|
xlock -mode blank -dpmsoff 1
|
|
;;
|
|
|
|
esac
|
|
|
|
# vim: ts=4
|