aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorache <ache@ache.one>2019-02-04 15:56:15 +0100
committerache <ache@ache.one>2019-02-04 15:56:15 +0100
commitfa994d1c81c890b9768e6a3f12267f44c574af3c (patch)
tree95c4fb4b91cfea3aeac88aecdf4dd89496ebd0c4
parentAdd euclide ¯\_(ツ)_/¯ (diff)
Various script
-rwxr-xr-xautoWall64
-rwxr-xr-xcoWifi65
2 files changed, 129 insertions, 0 deletions
diff --git a/autoWall b/autoWall
new file mode 100755
index 0000000..8b709ed
--- /dev/null
+++ b/autoWall
@@ -0,0 +1,64 @@
+#!/usr/bin/bash
+
+wallDir=/media/Wall
+
+for action in $@
+do
+ if [ ${action:0:1} = "+" ]
+ then
+ if [ -d ${wallDir}/${action:1} ]
+ then
+ echo ${action:1}/ >> ${wallDir}/listDirWall
+ fi
+ fi
+ if [ ${action} = "list" ]
+ then
+ for d in `ls ${wallDir}`
+ do
+ if [ -d "${wallDir}/${d}" ]; then
+ echo "$d/"
+ fi
+ done
+ echo
+ fi
+ if [ ${action:0:1} = "-" ]
+ then
+ if [ -d ${wallDir}/${action:1} ]
+ then
+ sed -i "/${action:1}/d" ${wallDir}/listDirWall
+ fi
+ fi
+ if [ ${action:0:1} = "=" ]
+ then
+ if [ -d ${wallDir}/${action:1} ]
+ then
+ sed -i "/^${action:1}\/$/d" ${wallDir}/listDirWall
+ fi
+ fi
+done
+
+cmpWall=0
+
+for ligne in `cat ${wallDir}/listDirWall`
+do
+ cmpWall=$(( cmpWall + `ls "${wallDir}/$ligne" | wc -l` ))
+ echo "$ligne : "
+done
+
+randWall=$[( $RANDOM % $cmpWall )]
+
+
+for ligne in `cat ${wallDir}/listDirWall`
+do
+ if [ `ls "${wallDir}/$ligne" | wc -l` -gt $randWall ]
+ then
+ echo ${wallDir}/$ligne`ls ${wallDir}/$ligne | head -n $randWall | tail -n 1` > ~/.actWall
+ nitrogen --set-zoom-fill ${wallDir}/$ligne`ls ${wallDir}/$ligne | head -n $randWall | tail -n 1`
+ echo "Wall set " ${wallDir}/$ligne`ls ${wallDir}/$ligne | head -n $randWall | tail -n 1`
+ break
+ else
+ randWall=$(( randWall - `ls "${wallDir}/$ligne" | wc -l` ))
+ fi
+done
+
+echo $cmpWall
diff --git a/coWifi b/coWifi
new file mode 100755
index 0000000..5e17619
--- /dev/null
+++ b/coWifi
@@ -0,0 +1,65 @@
+#!/bin/env bash
+
+interface="";
+
+
+function guess_wifi {
+ toAll="$1"
+ _interface=""
+ for i in `ls /sys/class/net/`; do
+ if [ -d "/sys/class/net/$i/wireless" ] ; then
+ _interface="$i"
+ fi
+ done
+ if [ -z $interface ] ; then
+# echo 'No Wireless interface found\nExit'
+ if [ "$toAll" == "all" ] ; then
+# echo 'flushing all'
+ _interface=all
+ else
+ echo "${_interface}"
+ exit 1
+ fi
+ fi
+ echo "${_interface}"
+}
+
+
+
+if [ "$1" == 'off' ] ; then
+ if [ -z "$2" ] ; then
+ interface=$(guess_wifi '')
+ else
+ interface=$(guess_wifi 'all')
+ fi
+ echo 'OFF'
+ sudo pkill -f dhcpcd
+ sudo pkill -f wpa_supplicant
+ if [ "${interface}" = 'all' ] ; then
+ sudo ip route flush all
+ else
+ sudo ip route flush dev "${interface}"
+ fi
+ sudo pkill -f ssh
+ exit 0
+elif [ -z "$1" ] ; then
+ interface=$(guess_wifi '')
+else
+ interface="$1"
+fi
+
+
+
+if [ -z "$2" ]
+then
+ sudo wpa_supplicant -B "-i${interface}" -D wext -c/etc/wpa_supplicant/wpa_supplicant.conf
+else
+ if [ -z "$3" ]
+ then
+ sudo iwconfig "${interface}" essid "$2"
+ else
+ sudo iwconfig "${interface}" ap "$3"
+ sudo iwconfig "${interface}" essid "$2"
+ fi
+fi
+sudo dhcpcd "${interface}"