Dépôt initial

vif
Olivier DOSSMANN 2019-10-03 22:56:50 +02:00
commit 534379a323
8 changed files with 228 additions and 0 deletions

View File

@ -0,0 +1 @@
sudo tee /sys/class/leds/asus::kbd_backlight/brightness <<< 0

1
bin/backlight_on 100755
View File

@ -0,0 +1 @@
sudo tee /sys/class/leds/asus::kbd_backlight/brightness <<< 1

129
bin/battery 100755
View File

@ -0,0 +1,129 @@
#!/bin/sh
HEART_FULL=♥
HEART_EMPTY=♡
[ -z "$NUM_HEARTS" ] &&
NUM_HEARTS=5
cutinate()
{
perc=$1
inc=$(( 100 / $NUM_HEARTS))
for i in `seq $NUM_HEARTS`; do
if [ $perc -lt 100 ]; then
echo $HEART_EMPTY
else
echo $HEART_FULL
fi
perc=$(( $perc + $inc ))
done
}
linux_get_bat ()
{
bf=$(cat $BAT_FULL)
bn=$(cat $BAT_NOW)
echo $(( 100 * $bn / $bf ))
}
openbsd_get_bat ()
{
bf=$(sysctl -n hw.sensors.acpibat0.amphour0 | cut -d ' ' -f 1)
bn=$(sysctl -n hw.sensors.acpibat0.amphour3 | cut -d ' ' -f 1)
echo "(($bn * 100) / $bf)" | bc -l | awk -F '.' '{ print $1 }';
}
freebsd_get_bat ()
{
sysctl -n hw.acpi.battery.life
}
battery_status()
{
case $(uname -s) in
"Linux")
BATPATH=${BATPATH:-/sys/class/power_supply/BAT1}
STATUS=$BATPATH/status
[ "$1" = `cat $STATUS` ] || [ "$1" = "" ] || return 0
if [ -f "$BATPATH/energy_full" ]; then
naming="energy"
elif [ -f "$BATPATH/charge_full" ]; then
naming="charge"
elif [ -f "$BATPATH/capacity" ]; then
cat "$BATPATH/capacity"
return 0
fi
BAT_FULL=$BATPATH/${naming}_full
BAT_NOW=$BATPATH/${naming}_now
linux_get_bat
;;
"FreeBSD")
STATUS=`sysctl -n hw.acpi.battery.state`
case $1 in
"Discharging")
if [ $STATUS -eq 1 ]; then
freebsd_get_bat
fi
;;
"Charging")
if [ $STATUS -eq 2 ]; then
freebsd_get_bat
fi
;;
"")
freebsd_get_bat
;;
esac
;;
"OpenBSD")
openbsd_get_bat
;;
"Darwin")
case $1 in
"Discharging")
ext="No";;
"Charging")
ext="Yes";;
esac
ioreg -c AppleSmartBattery -w0 | \
grep -o '"[^"]*" = [^ ]*' | \
sed -e 's/= //g' -e 's/"//g' | \
sort | \
while read key value; do
case $key in
"MaxCapacity")
export maxcap=$value;;
"CurrentCapacity")
export curcap=$value;;
"ExternalConnected")
if [ -n "$ext" ] && [ "$ext" != "$value" ]; then
exit
fi
;;
"FullyCharged")
if [ "$value" = "Yes" ]; then
exit
fi
;;
esac
if [[ -n "$maxcap" && -n $curcap ]]; then
echo $(( 100 * $curcap / $maxcap ))
break
fi
done
esac
}
BATTERY_STATUS=`battery_status $1`
[ -z "$BATTERY_STATUS" ] && exit
if [ -n "$CUTE_BATTERY_INDICATOR" ]; then
cutinate $BATTERY_STATUS
else
echo ${BATTERY_STATUS}%
fi

3
bin/current_date 100755
View File

@ -0,0 +1,3 @@
#!/usr/bin/env bash
LANG=fr_FR.UTF-8 date +'%R %a, le %d/%m/%Y'

34
bin/ostatus 100755
View File

@ -0,0 +1,34 @@
#!/usr/bin/env bash
#
# Script to send a status on GNUSocial instance using HTTPie
#
# Requirements: httpie package
SERVER='https://herds.eu'
API="${SERVER}/api"
URL="${API}/statuses/update.xml"
GS_USER='bl4n'
command -v http >/dev/null 2>&1 || { echo >&2 "httpie is missing!"; exit 1;}
message="$*"
if http --check-status --timeout=5 -a $GS_USER -f POST $URL source='HTTPie' status="$message" &> /dev/null; then
echo 'OK!'
else
case $? in
2) echo 'Request timed out!' && exit 1;;
3) echo 'Unexpected HTTP 3xx Redirection!' && exit 1 ;;
4) echo 'HTTP 4xx Client Error!' && exit 1;;
5) echo 'HTTP 5xx Server Error!' && exit 1;;
6) echo 'Exceeded --max-redirects=<n> redirects!' && exit 1 ;;
*) echo 'Other Error!' && exit 1;;
esac
fi
exit 0
# Some information about method
# EITHER HTTPIE
#http -f POST $URL -a $GS_USER source='HTTPie' status="$message"
# OR CURL
#curl -u $GS_USER $URL -d status='curlTest'

View File

@ -0,0 +1,3 @@
#!/usr/bin/env bash
chromium --proxy-server="socks4://localhost:9005"

View File

@ -0,0 +1,49 @@
#!/usr/bin/env bash
# random_wallpaper
#
# Requirement: feh (apt install feh)
directory="$HOME/wallpapers"
minutes=15
# Some tests
if [ -z "`which feh`" ]; then
echo "This script needs the feh program. Install it."
i exit 1
fi
if [ -d '$directory' ]; then
echo "No $directory found."
exit 1
fi
IFS="
"
array_files=($(ls -1 $directory))
nb_files=`ls $directory|wc -l`
if [ $nb_files == 0 ]; then
echo "$nb_files files in $directory"
exit 1
fi
# initialisation
seconds=$[ $minutes * 60 ]
while true; do
# Random number generator (not more than files number)
NUMBER=$[ ( $RANDOM % $nb_files ) ]
# Change background
file="${array_files["$NUMBER"]}"
feh --bg-fill "$directory/$file"
# Wait some times
sleep $seconds
done
exit 0

View File

@ -0,0 +1,8 @@
#!/usr/bin/env sh
IFS="
"
dir="/home/od/GOG Games/Stardew Valley/"
cd $dir && TERM=xterm ./start.sh