Organize scripts

This commit is contained in:
Şahin Akkaya 2022-03-01 16:07:01 +03:00
parent 95d8d8e1c4
commit 5630243ef1
11 changed files with 78 additions and 31 deletions

9
.config/crontab Normal file
View File

@ -0,0 +1,9 @@
DISPLAY=:0
XDG_RUNTIME_DIR=/run/user/1000
* * * * * /home/sahin/scripts/check-battery.sh 6
*/15 * * * * curl 'https://sks.itu.edu.tr/ExternalPages/sks/yemek-menu-v2/uzerinde-calisilan/yemek-menu.aspx' 2>/dev/null | grep -oP "js-nyro-modal.*?>\K(.+)(?=<i.*>)" > /home/sahin/.todaysmenu
* * * * * cat /var/spool/cron/sahin > /home/sahin/.config/crontab

View File

@ -1,4 +1,5 @@
# alias af=alias-finder
alias menu="menu | lolcat"
alias ls=lsd
alias lt="lsd --tree"
alias rake='noglob bundled_rake'

19
scripts/check-battery.sh Executable file
View File

@ -0,0 +1,19 @@
#!/bin/bash
# Set limit to shell argument
batteryLimit=$1
fullAt=92
# Get the current battery level with acpi
batteryLevel=$(acpi | cut -d ' ' -f 4 | tr -d '%|,| ')
charging=$(acpi | cut -d ' ' -f 3 | tr -d ',| ')
echo $batteryLevel
if [[ "$batteryLevel" -le "$batteryLimit" ]] && [[ "$charging" == "Discharging" ]]; then
/usr/bin/notify-send -a "Battery Warning" --urgency critical "Battery level at ${batteryLevel}%" -i abrt -t 10000
/usr/bin/paplay /usr/share/sounds/freedesktop/stereo/dialog-warning.oga
#elif [[ "$batteryLevel" -gt "$fullAt" ]] && [[ ! "$charging" == "Discharging" ]]; then
# /usr/bin/notify-send -a "Battery Warning" "Battery is full: ${batteryLevel}" -i abrt -t 10000
# /usr/bin/paplay /usr/share/sounds/freedesktop/stereo/dialog-warning.oga
fi

15
scripts/copy2clipboard Executable file
View File

@ -0,0 +1,15 @@
#!/bin/bash
if [ -z "$1" ]
then
file=$(find . -maxdepth 1 -type f | cut -c 3- | rofi -i -dmenu -p "Select file to copy its contents")
else
file=$1
fi
if [ -z "$file" ]; then
exit
fi
cat $file | xclip -selection c
notify-send "Contents of the '$file' is copied to clipboard!"

View File

@ -7,10 +7,10 @@ C='#ffffff22' # clear ish
# W='#880000bb' # wrong
# V='#bb00bbbb' # verifying
D="$(xrdb -query | grep "*.color12\b" | cut -d":" -f2 | xargs)cc"
T="$(xrdb -query | grep "*.color13\b" | cut -d":" -f2 | xargs)ee"
W="$(xrdb -query | grep "*.color1\b" | cut -d":" -f2 | xargs)bb"
V="$(xrdb -query | grep "*.color6\b" | cut -d":" -f2 | xargs)bb"
D="$(xrdb -query | grep ".color12" | cut -d":" -f2 | xargs)cc"
T="$(xrdb -query | grep ".color13" | cut -d":" -f2 | xargs)ee"
W="$(xrdb -query | grep ".color1" | cut -d":" -f2 | xargs)bb"
V="$(xrdb -query | grep ".color6" | cut -d":" -f2 | xargs)bb"
i3lock \

9
scripts/menu Executable file
View File

@ -0,0 +1,9 @@
#!/bin/bash
clear
figlet -f slant "Today's
menu"
cat ~/.todaysmenu
cowsay "Bon appetit!"

View File

@ -1,27 +0,0 @@
#!/bin/bash
# Set path for running in a cron job
PATH='/snap/bin:/home/sahin/.poetry/bin:/home/sahin/.pyenv/bin:/home/sahin/.pyenv/shims:/home/sahin/.pyenv/bin:/home/sahin/.cargo/bin:/home/sahin/.poetry/bin:/home/sahin/.local/bin:/home/sahin/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/usr/lib/jvm/java-8-oracle/bin:/usr/lib/jvm/java-8-oracle/db/bin:/usr/lib/jvm/java-8-oracle/jre/bin:/home/sahin/Downloads/ArchiveFiles/idea-IU-211.7628.21/bin:/home/sahin/scripts:/home/sahin/.fzf/bin'
# Set limit to shell argument
batteryLimit=$1
export DISPLAY=:0
export XDG_RUNTIME_DIR=/run/user/$(id -u)
# Get the current battery level with acpi
batteryLevel=$(acpi | cut -d ' ' -f 4 | tr -d '%|,| ')
charging=$(acpi | cut -d ' ' -f 3 | tr -d ',| ')
# Must have the Xdus file to run in a cron job. If this is not
# necessary functionality, this can be ignored, otherwise one must
# run the /scripts/xdbus.sh script in this repository at startup,
# which is called by default from my i3/config file.
# if [ -r "$HOME/.dbus/Xdbus" ]; then
# . "$HOME/.dbus/Xdbus"
# fi
if [[ "$batteryLevel" -le "$batteryLimit" ]] && [[ "$charging" == "Discharging" ]]; then
/usr/bin/notify-send -a "Battery Warning" --urgency critical "Battery level at ${batteryLevel}%" -i abrt -t 10000
/usr/bin/paplay /usr/share/sounds/Oxygen-K3B-Finish-Error.ogg
fi

14
scripts/shrfile Executable file
View File

@ -0,0 +1,14 @@
#!/bin/bash
if [ -z "$1" ]
then
file=$(find . -maxdepth 1 -type f | cut -c 3- | rofi -i -dmenu -p "Select file to share")
else
file=$1
fi
if [ -z "$file" ]; then
exit
fi
curl -F "file=@$file" https://0x0.st | xclip -selection c
notify-send "Link to $file is copied to clipboard!"

7
scripts/whereami Executable file
View File

@ -0,0 +1,7 @@
#!/bin/bash
ip=$(curl "https://api.ipify.org" 2>/dev/null)
res=$(curl -s "http://ip-api.com/json/$ip" 2>/dev/null)
# echo $res | jq '.'
echo $res | jq -r -j '.city, ", ", .country, "\n"'