diff --git a/bin/battery-daemon b/bin/battery-daemon new file mode 100755 index 0000000..f7febd6 --- /dev/null +++ b/bin/battery-daemon @@ -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 diff --git a/bin/last-pkg-updates b/bin/last-pkg-updates new file mode 100755 index 0000000..f72b064 --- /dev/null +++ b/bin/last-pkg-updates @@ -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'))" diff --git a/bin/lockscreen b/bin/lockscreen new file mode 100755 index 0000000..2021c0b --- /dev/null +++ b/bin/lockscreen @@ -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 diff --git a/bin/makescreenshot b/bin/makescreenshot new file mode 100755 index 0000000..0cb6db9 --- /dev/null +++ b/bin/makescreenshot @@ -0,0 +1,3 @@ +#!/bin/sh +XDG_CURRENT_DESKTOP="sway" +flameshot gui diff --git a/bin/upload-to-nextcloud b/bin/upload-to-nextcloud new file mode 100755 index 0000000..7264e7d --- /dev/null +++ b/bin/upload-to-nextcloud @@ -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" diff --git a/bin/xwingeometry b/bin/xwingeometry new file mode 100755 index 0000000..c467244 --- /dev/null +++ b/bin/xwingeometry @@ -0,0 +1,3 @@ +#!/bin/bash + +echo $(xwininfo | grep "geometry") diff --git a/bin/yt-music b/bin/yt-music new file mode 100755 index 0000000..6895d9c --- /dev/null +++ b/bin/yt-music @@ -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"