dotfiles/Utils/octopus.sh

246 lines
4.8 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")
2019-11-22 15:15:22 +00:00
amixer -q set Headphone toggle
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
;;
2017-03-27 23:07:07 +00:00
"on")
echo 1 | sudo tee /sys/devices/platform/thinkpad_acpi/leds/tpacpi::power/brightness
;;
esac
;;
"thinklight")
case $3 in
"off")
echo 0 | sudo tee /sys/devices/platform/thinkpad_acpi/leds/tpacpi::thinklight/brightness
;;
"on")
echo 1 | sudo tee /sys/devices/platform/thinkpad_acpi/leds/tpacpi::thinklight/brightness
;;
2015-03-01 17:44:25 +00:00
esac
;;
esac
;;
2013-12-02 22:37:14 +00:00
2013-06-11 20:39:53 +00:00
"monitor")
2019-08-28 15:59:12 +00:00
#SNU=`xrandr | grep VGA | cut -d' ' -f1 | cut -c4`
2019-11-22 15:15:22 +00:00
VGA=DP-1
PROJ=DP-1-3
2019-11-22 15:15:22 +00:00
LVDS=eDP-1
2013-06-11 20:39:53 +00:00
case $2 in
"proj")
xrandr --output $LVDS --off \
--output $VGA --off \
--output $PROJ --auto --rotate normal
;;
2013-06-11 20:39:53 +00:00
"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
;;
2017-03-27 23:07:07 +00:00
"music")
xrandr --output $LVDS --auto --rotate left \
--output $VGA --off
;;
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 \
2019-11-22 15:15:22 +00:00
--left-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
2019-08-28 15:59:12 +00:00
#$0 wallpaper
2013-06-11 20:39:53 +00:00
;;
"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-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`
2019-08-28 15:59:12 +00:00
xsetroot -name "$VOLUME :: Bat $BATT_PCT $BATT_TIME :: $DATE" || true
# $0 conf-ifaces
# $0 leds power off
2017-03-27 23:07:07 +00:00
$0 checkbatt
;;
"checkbatt")
2013-06-11 20:39:53 +00:00
;;
#BATT_PCT=$(acpi -b | cut -d, -f2 | cut -d" " -f2 | cut -d'%' -f1)
#if [ $BATT_PCT -le 15 ]; then
# # systemctl suspend -i
# true
# for i in `seq 10`; do
# $0 leds thinklight on
# sleep .1
# $0 leds thinklight off
# sleep .1
# done
#fi;
#;;
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")
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
2019-08-28 15:59:12 +00:00
$0 monitor dual
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 &
2019-08-28 15:59:12 +00:00
#/home/frank/Programmation/dotfiles/lock/i3lock-color/lock.sh
#$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