Update dotfiles

This commit is contained in:
hok7z 2023-07-11 17:06:43 +03:00
parent 0c5efa383b
commit 596caccfa4
7 changed files with 149 additions and 0 deletions

34
bin/battery-daemon Executable file
View File

@ -0,0 +1,34 @@
#!/bin/sh
for pid in $(pidof -x battery); do
if [ "$pid" != $$ ]; then
kill -9 "$pid"
fi
done
notify_icons="/home/q/.config/dunst/icons"
# notify when below this percentage
warning_level=30
# how often to check battery status, in seconds
check_interval=300
while true; do
path_to_battery=$(upower -e | grep BAT)
battery_level=$(upower -i "$path_to_battery" | grep -E "percentage" | sed 's/[^0-9]//g')
discharging=$(upower -i "$path_to_battery" | grep -E "state" | grep -c "discharging")
time_to_empty=$(upower -i "$path_to_battery" | grep -E "time to empty" | sed 's/[^0-9,.]//g')
# check if battery is low and discharging
if [ "$battery_level" -lt "$warning_level" ] && [ "$discharging" -eq 1 ]
then
dunstify -a "Battery" \
"Low battery: ${battery_level}%" \
"Battery is low ($time_to_empty hours left)" \
-r 100 \
-i "$notify_icons/battery-low.png"
mpv "/home/q/.config/alarm/low-battery-sound.mp3"
fi
sleep ${check_interval}s
done

5
bin/last-pkg-updates Executable file
View File

@ -0,0 +1,5 @@
#!/bin/sh
last_pkg_updates=$(grep 'pacman -Suuy' /var/log/pacman.log | tail -1 | tr -d '[' | cut -f 1 -d 'T')
echo "Last update: $last_pkg_updates ($(date +'%Y-%m-%d'))"

15
bin/lockscreen Executable file
View File

@ -0,0 +1,15 @@
#!/bin/sh
swaylock \
--screenshots \
--clock \
--indicator \
--indicator-radius 100 \
--indicator-thickness 7 \
--effect-blur 7x5 \
--effect-vignette 0.5:0.5 \
--ring-color 2e3440 \
--key-hl-color 88C0D0 \
--line-color 00000000 \
--inside-color 00000088 \
--separator-color 00000000 \
--layout-text-color ffffffffff

3
bin/makescreenshot Executable file
View File

@ -0,0 +1,3 @@
#!/bin/sh
XDG_CURRENT_DESKTOP="sway"
flameshot gui

68
bin/upload-to-nextcloud Executable file
View File

@ -0,0 +1,68 @@
#!/bin/bash
username="user"
password="pass123456"
url="https://domain.nextcloud.com/remote.php/dav/files/$username"
if [[ $# -lt 2 ]]; then
echo "upload-to-nextcloud - upload directory to nextcloud"
echo "Usage: ./upload-to-nextcloud [local directory] [remote directory]"
exit 0
fi
function create_directory {
local directory_path=$1
local directory_name=$(basename "$directory_path")
local source_path="$2"
if [ -z "$source_path" ]; then
source_path=$(dirname "$directory_path")
fi
local remote_dir="$3"
local create_dir_url="$url/$remote_dir${directory_path#$source_path}/"
create_dir_url="${create_dir_url// /%20}"
curl -u "$username:$password" -X MKCOL "$create_dir_url"
}
function upload_file {
local file_path=$1
local file_name=$(basename "$file_path")
local source_path="$2"
if [ -z "$source_path" ]; then
source_path=$(dirname "$file_path")
fi
local remote_dir="$3"
local upload_url="$url/$remote_dir${file_path#$source_path}"
upload_url="${upload_url// /%20}"
echo $upload_url
curl -u "$username:$password" -T "$file_path" "$upload_url"
}
function upload_to_nextcloud {
local local_dir=$1
local remote_dir=$2
local source_path=$3
if [ -z "$source_path" ]; then
source_path=$local_dir
fi
for file in "$local_dir"/*; do
if [[ -f "$file" ]]; then
upload_file "$file" "$source_path" "$remote_dir"
elif [[ -d "$file" ]]; then
create_directory "$file" "$source_path" "$remote_dir"
upload_to_nextcloud "$file" "$remote_dir" "$source_path"
fi
done
}
upload_to_nextcloud "$1" "$2"

3
bin/xwingeometry Executable file
View File

@ -0,0 +1,3 @@
#!/bin/bash
echo $(xwininfo | grep "geometry")

21
bin/yt-music Executable file
View File

@ -0,0 +1,21 @@
#!/bin/bash
if [[ $# -lt 2 ]]; then
echo "yt-music - download music from youtube"
echo "Using: ./yt-music [link] \"Autor - Song\" (yt-dlp args)"
exit 0
fi
filename="${2}.mp3"
IFS="-" read -a array <<< "$2"
artist=${array[0]}
artist=`echo $artist | sed 's/ *$//g'`
song=${array[1]}
song=`echo $song | sed 's/ *$//g'`
yt-dlp $1 -x --audio-format mp3 -o "$filename" $3
id3v2 -a "${artist}" "$filename"
id3v2 -t "${song}" "$filename"