diff --git a/.config/crontab b/.config/crontab index 29f8437..ab3e879 100644 --- a/.config/crontab +++ b/.config/crontab @@ -2,8 +2,24 @@ DISPLAY=:0 XDG_RUNTIME_DIR=/run/user/1000 + +# Example of job definition: +# .---------------- minute (0 - 59) +# | .------------- hour (0 - 23) +# | | .---------- day of month (1 - 31) +# | | | .------- month (1 - 12) OR Jan-Dec +# | | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR SUN-SAT +# | | | | | +# * * * * * user-name command to be executed + +# * any value +# , value list separator +# - range of values +# / step values + * * * * * /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(.+)(?=)" > /home/sahin/.todaysmenu +# At every 15th minute past every hour from 6 through 16. +*/15 06-16 * * * 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(.+?)(?=<[is].*>)" > /home/sahin/.cronresults/todaysmenu * * * * * cat /var/spool/cron/sahin > /home/sahin/.config/crontab diff --git a/scripts/adjust_terminal_colors.py b/scripts/adjust_terminal_colors.py deleted file mode 100755 index 9080a6f..0000000 --- a/scripts/adjust_terminal_colors.py +++ /dev/null @@ -1,52 +0,0 @@ -#!/usr/bin/env python3 -import sys -import pywal -from subprocess import check_output -import json - -colorspace = sys.argv[1] -fraction = sys.argv[2] -generate_from_old_colors = len(sys.argv) == 4 -# get current color scheme -if generate_from_old_colors: - generated_colors = pywal.colors.file("/home/sahin/.cache/wal/.old_colors.json") -else: - generated_colors = pywal.colors.file("/home/sahin/.cache/wal/colors.json") - -reference_colors = ['black', 'red', 'green', 'yellow', 'blue' , 'magenta', 'cyan', 'white'] - -with open("/home/sahin/.cache/wal/.old_colors.json", 'w') as f: - json.dump(generated_colors, f) - - -# we will only use first 8 colors in the terminal -terminal_colors = list(generated_colors['colors'].items())[:8] - -for (name, t), ref in zip(terminal_colors, reference_colors): - command = f"pastel mix {t[1:]} {ref} "\ - f"--colorspace={colorspace} "\ - f"--fraction={fraction} | pastel format" - generated_colors['colors'][name] = check_output(command, - shell=True).decode('utf8').strip() - -# generated_colors['special']['background'] = generated_colors['colors']['color0'] -# generated_colors['special']['foreground'] = generated_colors['colors']['color7'] -# generated_colors['special']['cursor'] = generated_colors['colors']['color7'] -# print(colors) - -# image = generated_colors["wallpaper"] - -# Apply the palette to all open terminals. -# Second argument is a boolean for VTE terminals. -# Set it to true if the terminal you're using is -# VTE based. (xfce4-terminal, termite, gnome-terminal.) -pywal.sequences.send(generated_colors) - -# Export all template files. -pywal.export.every(generated_colors) - -# Reload xrdb, i3 and polybar. -# pywal.reload.env() - -# Set the wallpaper. -# pywal.wallpaper.change(image) diff --git a/scripts/chlayout b/scripts/chlayout new file mode 100755 index 0000000..428b2b7 --- /dev/null +++ b/scripts/chlayout @@ -0,0 +1,11 @@ +#!/bin/bash + + +variant=$(setxkbmap -query | grep variant | cut -d" " -f5) + +if [[ $variant == "cdhisopt" ]] + then + setxkbmap us cdhpt -option '' +else + setxkbmap us cdhisopt 'caps:ctrl_modifier' +fi diff --git a/scripts/copy2clipboard b/scripts/copy2clipboard deleted file mode 100755 index dac5e37..0000000 --- a/scripts/copy2clipboard +++ /dev/null @@ -1,15 +0,0 @@ -#!/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!" diff --git a/scripts/cpyfile b/scripts/cpyfile new file mode 100755 index 0000000..4842b7f --- /dev/null +++ b/scripts/cpyfile @@ -0,0 +1,21 @@ +#!/bin/bash + +if [ -z "$1" ] + then + files=( $(find . -maxdepth 1 -type f | cut -c 3- | rofi -i -dmenu -p "Select a file to copy") ) + else + files=("$@") +fi + + +if [ -z "$files" ]; then + exit +fi + +args=() +for arg in "${files[@]}"; do + fullpath=$(readlink -f $arg) + args+=("file://$fullpath") +done + +printf '%s\n' "${args[@]}" | xclip -i -sel clipboard -t text/uri-list diff --git a/scripts/cpyout b/scripts/cpyout new file mode 100755 index 0000000..4145c00 --- /dev/null +++ b/scripts/cpyout @@ -0,0 +1,11 @@ +#!/bin/bash + +tmpfile=$(mktemp /tmp/cmd-output.XXXXXX) +trap 'rm "$tmpfile"' 0 1 15 +echo "\$ $@" | tee $tmpfile +eval "$@" |& tee -a $tmpfile + + +cat $tmpfile | xclip -sel c + + diff --git a/scripts/dynamic-wallpaper.sh b/scripts/dynamic-wallpaper.sh deleted file mode 100755 index e581f97..0000000 --- a/scripts/dynamic-wallpaper.sh +++ /dev/null @@ -1,40 +0,0 @@ -#!/bin/bash - -# get todays md5sum and extract first 2 chars then convert it to base 10 -randomizer=$(cat ~/.wallpaper_randomizer) -today=$(date +%x) -todays_hash=$(echo "$randomizer $today" | md5sum | cut -c 1-2) -base10=$(echo $((0x$todays_hash)) | bc) - -echo "base 10 ${base10}" - -# calculate the index for the wallpaper set: base10 % num_of_dirs -dirs=$(find ~/Pictures/Wallpapers/time-based/* -maxdepth 1 -type d) -num_of_dirs=$(echo "${dirs}" | wc -l) -index=$(echo "${base10} % ${num_of_dirs} + 1" | bc) -wallpaper_set=$(echo "${dirs}"| sed -n "${index}p") - -# get the file path based on the current hour of the day -num=$(date +%-H) -image="$wallpaper_set/$num" -if [[ -f "${image}.png" ]]; then - format="png" -elif [[ -f "${image}.jpg" ]]; then - format="jpg" -else - notify-send "Could not find any image for $image" -fi -path="$wallpaper_set/$num.$format" -echo "path: $path" -actual_file=$(readlink -f $path) - -set_wallpaper() { - wal -st -i $1 --backend=haishoku - python3 ~/scripts/misc/adjust_terminal_colors.py rgb 0.5 - ~/scripts/misc/restart_dunst.sh - xrdb ~/.Xresources - -} -# if the current wallpaper is different than the previous one, set it -[[ $(< ~/.last_wallpaper_path) != "$actual_file" || $1 ]] && set_wallpaper $actual_file -echo "$actual_file" > ~/.last_wallpaper_path diff --git a/scripts/getlength b/scripts/getlength new file mode 100755 index 0000000..f07d6c1 --- /dev/null +++ b/scripts/getlength @@ -0,0 +1,2 @@ +date -u -d @`find . -maxdepth 1 -iname '*.mp4' -exec ffprobe -v quiet -of csv=p=0 -show_entries format=duration {} \; | paste -sd+ -| bc` +"%T" + diff --git a/scripts/git-rm-untracked b/scripts/git-rm-untracked new file mode 100755 index 0000000..a0cc80e --- /dev/null +++ b/scripts/git-rm-untracked @@ -0,0 +1,5 @@ +#!/bin/bash + + +git ls-files -o | xargs -t rm + diff --git a/scripts/menu b/scripts/menu index aab74e2..ae4c820 100755 --- a/scripts/menu +++ b/scripts/menu @@ -4,6 +4,6 @@ figlet -f slant "Today's menu" -cat ~/.todaysmenu +cat ~/.cronresults/todaysmenu cowsay "Bon appetit!" diff --git a/scripts/restart_dunst.sh b/scripts/restart_dunst.sh deleted file mode 100755 index 0e2a9f5..0000000 --- a/scripts/restart_dunst.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh -killall dunst -dunst & -notify-send "Environment reloaded!" diff --git a/scripts/search-notes.sh b/scripts/search-notes.sh new file mode 100755 index 0000000..155433d --- /dev/null +++ b/scripts/search-notes.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +tmux popup \ + -w 90% \ + -h 90% \ + -x C \ + -y C \ + -E "/home/sahin/scripts/search-with-ag.sh" diff --git a/scripts/search-with-ag.sh b/scripts/search-with-ag.sh new file mode 100755 index 0000000..e19ad31 --- /dev/null +++ b/scripts/search-with-ag.sh @@ -0,0 +1,11 @@ +#!/bin/bash +result=$(ag --nobreak --nonumbers --noheading . ~/GitRepositories/til/ | fzf --ansi --preview='file=$(echo {} | cut -d':' -f1); bat --style=numbers,changes --wrap never --color always $file') + + +# do not use the following because it does not show anything if it can't find exact match inside the file. kills the point of fuzzy finding +# result=$(ag --nobreak --nonumbers --noheading . /home/sahin/PythonProjects/til/ | fzf --ansi --preview='file=$(echo {} | cut -d':' -f1); batgrep --color --context 100 {q} $file') + +if [ ! "$result" ];then + exit 0 +fi +/home/sahin/.local/bin/lvim $(echo $result | cut -d':' -f1) diff --git a/scripts/shrfile b/scripts/shrfile index 6676cc9..4899333 100755 --- a/scripts/shrfile +++ b/scripts/shrfile @@ -12,3 +12,4 @@ if [ -z "$file" ]; then fi curl -F "file=@$file" https://0x0.st | xclip -selection c notify-send "Link to $file is copied to clipboard!" +echo "$(xclip -o -sel clipboard)" diff --git a/scripts/shrout b/scripts/shrout new file mode 100755 index 0000000..ab8552f --- /dev/null +++ b/scripts/shrout @@ -0,0 +1,24 @@ +#!/bin/bash + +tmpfile=$(mktemp /tmp/cmd-output.XXXXXX) +trap 'rm "$tmpfile"' 0 1 15 +echo "\$ $@" | tee $tmpfile +eval "$@" |& tee -a $tmpfile + +read -p "Sharing output. [O]k, [e]dit, [d]iscard? " -n1 ans; + + +echo +case "$ans" in + o|O) ;; + e|E) $EDITOR $tmpfile + ;; + d|D) exit 0 + ;; + *) exit 1 + ;; +esac + +shrfile $tmpfile 2>/dev/null + + diff --git a/scripts/toggle-screenkey b/scripts/toggle-screenkey new file mode 100755 index 0000000..52de2f2 --- /dev/null +++ b/scripts/toggle-screenkey @@ -0,0 +1,11 @@ +#!/bin/bash + +num=$(ps aux | grep /usr/bin/screenkey | wc -l) + +if [[ $num -eq 1 ]]; then + screenkey & + notify-send "Screenkey enabled." +else + pkill screenkey + notify-send "Screenkey disabled." +fi diff --git a/scripts/toggle-touchpad.sh b/scripts/toggle-touchpad.sh new file mode 100755 index 0000000..a671074 --- /dev/null +++ b/scripts/toggle-touchpad.sh @@ -0,0 +1,11 @@ +export `xinput list | grep -i touchpad | awk '{ print $6 }'` +TOUCH_ENABLED=`xinput list-props $id | grep Device\ Enabled | awk '{ print $4 }'` +if [ $TOUCH_ENABLED = 0 ]; then + xinput set-prop $id "Device Enabled" 1 +elif [ $TOUCH_ENABLED = 1 ]; then + xinput set-prop $id "Device Enabled" 0 +else + echo "Could not get touchpad status from xinput" + exit 1 +fi +exit 0 diff --git a/scripts/webcam b/scripts/webcam new file mode 100755 index 0000000..aeccfd3 --- /dev/null +++ b/scripts/webcam @@ -0,0 +1,12 @@ +#!/bin/bash + +if [ -z "$1" ] + then + res="300" + else + res=$1 +fi + +v4l2-ctl --set-fmt-video=width=$res,height=$res +mpv /dev/video0 + diff --git a/scripts/whereami b/scripts/whereami index ed234ae..8db931c 100755 --- a/scripts/whereami +++ b/scripts/whereami @@ -1,7 +1,5 @@ #!/bin/bash -ip=$(curl "https://api.ipify.org" 2>/dev/null) - -res=$(curl -s "http://ip-api.com/json/$ip" 2>/dev/null) +res=$(curl -s "http://ip-api.com/json/" 2>/dev/null) # echo $res | jq '.' echo $res | jq -r -j '.city, ", ", .country, "\n"'