263 lines
6.1 KiB
Bash
Executable file
263 lines
6.1 KiB
Bash
Executable file
#!/bin/bash
|
|
### T0MuX CTRL Script "tcs" v1.0beta ###
|
|
|
|
# Emplacement absolu des sons, ils seront lu SI ils existent. Pour ne pas les utiliser, les supprimer.
|
|
snd=/home/t0mux/scripts/tcs
|
|
|
|
# Commande de lancement du navigateur (ex: "palemoon -new-window", "midori", "firefox-bin -new-tab -no-remote")
|
|
nav=qutebrowser
|
|
|
|
# Commandes pour lancer les elements du bureau
|
|
panel=
|
|
dock=
|
|
composite=compton
|
|
composite_args="--backend glx -cCGfF -e0.8 -o0.7 -t0 -l0 -r6 -D8 -m 0.8 --shadow-exclude"
|
|
conky_cmd="conky -c ~/.config/conky/conkyrc&conky -c ~/.config/conky/conkydo&conky -c ~/.config/conky/conkysys&conky -c ~/.config/conky/conkyram&conky -c ~/.config/conky/conkycpu&"
|
|
|
|
#### A FAIRE ###
|
|
# saveconf
|
|
# merge UP et URL
|
|
# RECUP les sons pour la partie volume
|
|
|
|
# SEARCH
|
|
search() {
|
|
case $1 in
|
|
qw)
|
|
echo -ne "\033]0;"Recherche Qwant"\007"
|
|
read -p "" search
|
|
$nav https://www.qwant.com/?q="$search"'&t'=web
|
|
;;
|
|
qwi)
|
|
echo -ne "\033]0;"Recherche Qwant Images"\007"
|
|
read -p "" search
|
|
$nav https://www.qwant.com/?q="$search"'&t'=images &
|
|
#exec i3 workspace Recherche Qwant Images
|
|
;;
|
|
ddg)
|
|
echo -ne "\033]0;"Recherche DuckDuckGo"\007"
|
|
read -p "" search
|
|
$nav https://duckduckgo.com/?t=palemoon'&q='"$search"'&ia'=web &
|
|
#exec i3 workspace Recherche DuckDuckGo
|
|
;;
|
|
ddgi)
|
|
echo -ne "\033]0;"Recherche DuckDuckGo Images"\007"
|
|
read -p "" search
|
|
$nav https://duckduckgo.com/?t=palemoon'&q='"$search"'&iax=1&'ia=images &
|
|
#exec i3 workspace Recherche DuckDuckGo Images
|
|
;;
|
|
eco)
|
|
echo -ne "\033]0;"Recherche Ecosia"\007"
|
|
read -p "" search
|
|
$nav https://www.ecosia.org/search?q="$search" &
|
|
#exec i3 workspace Recherche Ecosia
|
|
;;
|
|
*)
|
|
echo "Unknown fruit - sure it isn't toxic?"
|
|
exit
|
|
esac
|
|
}
|
|
|
|
# Screen - dependances : xclip, scrot, curl +alsa-utils pour le son
|
|
screen() {
|
|
scrdate=`date +%Y%m%d-%H%M%S`
|
|
# Emplacement des captures écrans
|
|
scrpath=$HOME/Images/Screenshots/
|
|
|
|
scrfile=${scrpath}Scr_$scrdate.png
|
|
|
|
# Création du dossier $scrpath si il n'existe pas
|
|
if [ ! -f $scrpath ]; then mkdir -p $scrpath; fi
|
|
|
|
if [ -z ${2+x} ]; then
|
|
if [ "$1" = "f" ]; then
|
|
scrot $scrfile
|
|
fi
|
|
if [ "$1" = "s" ]; then
|
|
scrot $scrfile -s
|
|
fi
|
|
else
|
|
if [ "$1" = "f" ]; then
|
|
scrot $scrfile -d$2
|
|
fi
|
|
if [ "$1" = "s" ]; then
|
|
scrot $scrfile -s -d$2
|
|
fi
|
|
fi
|
|
|
|
aplay -q $snd/Camera.wav && aplay -q $snd/modem_long.wav > /dev/null 2>&1 &
|
|
curl -F"file=@${scrfile}" https://0x0.st | xclip -selection primary
|
|
pkill aplay && aplay -q $snd/Slap_low.wav
|
|
}
|
|
|
|
# UP & URL - Dépendances : curl + alsa-utils pour le son
|
|
up() {
|
|
aplay -q $snd/modem_long.wav > /dev/null 2>&1 &
|
|
curl -F"file=@$1" https://0x0.st | xclip -selection c
|
|
pkill aplay && aplay -q $snd/Slap_low.wav
|
|
if [ ! -f /usr/bin/xclip ]; then echo xclip non installé; fi
|
|
}
|
|
url() {
|
|
aplay -q $snd/modem_long.wav > /dev/null 2>&1 &
|
|
curl -F"shorten=$1" https://0x0.st | xclip -selection c
|
|
pkill aplay && aplay -q $snd/Slap_low.wav
|
|
if [ ! -f /usr/bin/xclip ]; then echo xclip non installé; fi
|
|
}
|
|
|
|
|
|
# BashCalc - Dépendance : bc
|
|
bashcalc() {
|
|
echo -ne "\033]0;"BashCalc"\007"
|
|
echo "Calculette à l'ancienne mon gars :D"
|
|
echo
|
|
while :
|
|
do
|
|
read -p "" calc
|
|
echo -e $calc | bc -l
|
|
echo
|
|
done
|
|
}
|
|
|
|
# Volume - Dépendances : MOC (lecteur audio) + alsa-utils pour le son
|
|
volume() {
|
|
if [ "$1" = "up" ]; then
|
|
amixer -c 0 sset Master 4%+
|
|
if [ "`mocp -i`" = "State: STOP" ] || [ "`mocp -i | grep State`" = "State: PAUSE" ]
|
|
then aplay /home/t0mux/SOFT/LINUX/theme/sounds/T0MuX/button-pressed.wav
|
|
fi
|
|
fi
|
|
|
|
if [ "$1" = "down" ]; then
|
|
amixer -c 0 sset Master 4%-
|
|
if [ "`mocp -i`" = "State: STOP" ] || [ "`mocp -i | grep State`" = "State: PAUSE" ]
|
|
then aplay /home/t0mux/SOFT/LINUX/theme/sounds/T0MuX/button-pressed.wav
|
|
fi
|
|
fi
|
|
|
|
if [ "$1" = "mute" ]; then
|
|
amixer -c 0 sset Master toggle &&
|
|
if [ "`amixer -c 0 sget Master | grep % | cut -d ' ' -f 8 | tr -d []`" = off ]
|
|
then notify-send 'Volume' 'Mute' --icon=audio-volume-muted
|
|
else notify-send 'Volume' 'Unmuted' --icon=audio-volume-high
|
|
fi
|
|
fi
|
|
}
|
|
|
|
# Colors
|
|
colors() {
|
|
for clbg in {40..47} {100..107} 49 ; do
|
|
#Foreground
|
|
for clfg in {30..37} {90..97} 39 ; do
|
|
#Formatting
|
|
for attr in 0 1 2 4 5 7 ; do
|
|
#Print the result
|
|
echo -en "\e[${attr};${clbg};${clfg}m ^[${attr};${clbg};${clfg}m \e[0m"
|
|
done
|
|
echo #Newline
|
|
done
|
|
done
|
|
|
|
exit 0
|
|
}
|
|
|
|
# ISO mounter/unmounter - PAS AU POINT
|
|
iso() {
|
|
mntdir="$2-mount"
|
|
case $1 in
|
|
m|mount)
|
|
if [ ! -f $mntdir ]; then mkdir $mntdir; fi
|
|
archivemount $2 $mntdir
|
|
;;
|
|
u|umount)
|
|
fusermount -u $mntdir
|
|
sleep 1
|
|
rm -R $mntdir
|
|
;;
|
|
*)
|
|
echo "Mauvais arguments."
|
|
echo " "
|
|
help
|
|
;;
|
|
esac
|
|
}
|
|
|
|
# Reconfigure
|
|
reconfigure() {
|
|
pkill $panel
|
|
pkill $dock
|
|
pkill $composite
|
|
pkill $conky
|
|
$panel & $dock & $composite $composite_args & $conky_cmd &
|
|
}
|
|
|
|
|
|
# HELP
|
|
help() {
|
|
echo "T0MuX Control Script - 1.0beta - 16/04/17"
|
|
echo
|
|
echo "Syntaxe : tcs [OPTION] [argument]"
|
|
echo
|
|
echo "# Recherche internet :"
|
|
echo " tcs <s|search> qw Qwant"
|
|
echo " qwi Qwant Images"
|
|
echo " ddg DuckDuckGo"
|
|
echo " ddgi DuckDuckGo Images"
|
|
echo " eco Ecosia"
|
|
echo
|
|
echo "# Calculette BC"
|
|
echo " tcs bc"
|
|
echo
|
|
echo "# Screencurl - capture écran + upload + retour lien dans clipboard"
|
|
echo " tcs <scr|screen> <f|s> <N>"
|
|
echo " f Capture tout l'écran"
|
|
echo " s Capture avec selection"
|
|
echo " N Délai de capture en secondes (0 si non-précisé)"
|
|
echo
|
|
echo "# Reconfigure - kill et relance les elements du bureau"
|
|
echo " tcs <r|reconf>"
|
|
echo
|
|
echo "# Volume"
|
|
echo " tcs <v|vol|volume> up monte le volume"
|
|
echo " down baisse le volume"
|
|
echo " mute coupe/remet le son"
|
|
echo
|
|
|
|
}
|
|
|
|
# Interprétation des arguments
|
|
case $1 in
|
|
s|search)
|
|
search $2
|
|
;;
|
|
scr|screen)
|
|
screen $2 $3
|
|
;;
|
|
up)
|
|
up $2
|
|
;;
|
|
url)
|
|
url $2
|
|
;;
|
|
bc|bashcalc)
|
|
bashcalc
|
|
;;
|
|
v|vol|volume)
|
|
volume $2
|
|
;;
|
|
c|colors)
|
|
colors
|
|
;;
|
|
i|iso)
|
|
iso $2 $3 &
|
|
;;
|
|
r|reconf)
|
|
reconfigure &
|
|
;;
|
|
h|help)
|
|
help
|
|
;;
|
|
*)
|
|
echo "Mauvais arguments."
|
|
echo " "
|
|
help
|
|
;;
|
|
esac
|