mirror of
https://github.com/sahinakkaya/dotfiles.git
synced 2024-12-23 07:39:36 +01:00
Add new scripts
This commit is contained in:
parent
5630243ef1
commit
d051d7ddca
@ -2,8 +2,24 @@
|
|||||||
DISPLAY=:0
|
DISPLAY=:0
|
||||||
XDG_RUNTIME_DIR=/run/user/1000
|
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
|
* * * * * /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
|
# 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
|
* * * * * cat /var/spool/cron/sahin > /home/sahin/.config/crontab
|
||||||
|
@ -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)
|
|
11
scripts/chlayout
Executable file
11
scripts/chlayout
Executable file
@ -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
|
@ -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!"
|
|
21
scripts/cpyfile
Executable file
21
scripts/cpyfile
Executable file
@ -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
|
11
scripts/cpyout
Executable file
11
scripts/cpyout
Executable file
@ -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
|
||||||
|
|
||||||
|
|
@ -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
|
|
2
scripts/getlength
Executable file
2
scripts/getlength
Executable file
@ -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"
|
||||||
|
|
5
scripts/git-rm-untracked
Executable file
5
scripts/git-rm-untracked
Executable file
@ -0,0 +1,5 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
|
||||||
|
git ls-files -o | xargs -t rm
|
||||||
|
|
@ -4,6 +4,6 @@ figlet -f slant "Today's
|
|||||||
menu"
|
menu"
|
||||||
|
|
||||||
|
|
||||||
cat ~/.todaysmenu
|
cat ~/.cronresults/todaysmenu
|
||||||
|
|
||||||
cowsay "Bon appetit!"
|
cowsay "Bon appetit!"
|
||||||
|
@ -1,4 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
killall dunst
|
|
||||||
dunst &
|
|
||||||
notify-send "Environment reloaded!"
|
|
8
scripts/search-notes.sh
Executable file
8
scripts/search-notes.sh
Executable file
@ -0,0 +1,8 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
tmux popup \
|
||||||
|
-w 90% \
|
||||||
|
-h 90% \
|
||||||
|
-x C \
|
||||||
|
-y C \
|
||||||
|
-E "/home/sahin/scripts/search-with-ag.sh"
|
11
scripts/search-with-ag.sh
Executable file
11
scripts/search-with-ag.sh
Executable file
@ -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)
|
@ -12,3 +12,4 @@ if [ -z "$file" ]; then
|
|||||||
fi
|
fi
|
||||||
curl -F "file=@$file" https://0x0.st | xclip -selection c
|
curl -F "file=@$file" https://0x0.st | xclip -selection c
|
||||||
notify-send "Link to $file is copied to clipboard!"
|
notify-send "Link to $file is copied to clipboard!"
|
||||||
|
echo "$(xclip -o -sel clipboard)"
|
||||||
|
24
scripts/shrout
Executable file
24
scripts/shrout
Executable file
@ -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
|
||||||
|
|
||||||
|
|
11
scripts/toggle-screenkey
Executable file
11
scripts/toggle-screenkey
Executable file
@ -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
|
11
scripts/toggle-touchpad.sh
Executable file
11
scripts/toggle-touchpad.sh
Executable file
@ -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
|
12
scripts/webcam
Executable file
12
scripts/webcam
Executable file
@ -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
|
||||||
|
|
@ -1,7 +1,5 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
ip=$(curl "https://api.ipify.org" 2>/dev/null)
|
res=$(curl -s "http://ip-api.com/json/" 2>/dev/null)
|
||||||
|
|
||||||
res=$(curl -s "http://ip-api.com/json/$ip" 2>/dev/null)
|
|
||||||
# echo $res | jq '.'
|
# echo $res | jq '.'
|
||||||
echo $res | jq -r -j '.city, ", ", .country, "\n"'
|
echo $res | jq -r -j '.city, ", ", .country, "\n"'
|
||||||
|
Loading…
Reference in New Issue
Block a user