Update: Changed scipts, updated readme.

This commit is contained in:
Keyitdev
2022-06-22 19:27:20 +02:00
parent 35c6ea42ec
commit c589d31ace
11 changed files with 208 additions and 163 deletions
+15 -15
View File
@@ -1,35 +1,35 @@
#!/bin/bash
#!/bin/sh
for pid in $(pidof -x battery); do
if [ $pid != $$ ]; then
kill -9 $pid
if [ "$pid" != $$ ]; then
kill -9 "$pid"
fi
done
DIR_ICONS="/usr/local/bin/icons"
dir_icons="/usr/local/bin/icons"
# Notify when below this percentage
WARNING_LEVEL=15
# notify when below this percentage
warning_level=15
# How often to check battery status, in minutes
CHECK_INTERVAL=1
# how often to check battery status, in minutes
check_interval=1
while true; do
battery_level=$(acpi -b \
| cut -d, -f2 | cut --characters=2,3,4 \
| sed 's/%//g')
charging=$(acpi -b | grep -c "Charging")
charging=$(acpi -b | grep -c "charging")
# When battery is low, and not already charging
if [ $battery_level -lt $WARNING_LEVEL ] &&
[ $charging -eq 0 ]
# when battery is low, and not already charging
if [ "$battery_level" -lt "$warning_level" ] &&
[ "$charging" -eq 0 ]
then
dunstify -a "Battery" \
"Low battery: ${battery_level}%" \
"Battery is running low" \
-r 100 \
-i $DIR_ICONS/battery.svg
-i $dir_icons/battery.svg
fi
sleep ${CHECK_INTERVAL}m
done
sleep ${check_interval}m
done
+10 -10
View File
@@ -1,23 +1,23 @@
#!/bin/bash
#!/bin/sh
DIR_ICONS="/usr/local/bin/icons"
dir_icons="/usr/local/bin/icons"
MAX_BRI=$(cat /sys/class/backlight/*/max_brightness)
CUR_BRI=$(cat /sys/class/backlight/*/brightness)
max_bri=$(cat /sys/class/backlight/*/max_brightness)
cur_bri=$(cat /sys/class/backlight/*/brightness)
# calculating current percentage
((CUR_PER = CUR_BRI * 100 / MAX_BRI))
cur_per=$((cur_bri * 100 / max_bri))
if [ $CUR_PER -ge 50 ]; then
if [ "$cur_per" -ge 50 ]; then
dunstify -a "Brightness" \
"Brightness" \
"Current brightness is $CUR_PER%" \
"Current brightness is $cur_per%" \
-r 100 \
-i $DIR_ICONS/sun.svg
-i "$dir_icons"/sun.svg
else
dunstify -a "Brightness" \
"Brightness" \
"Current brightness is $CUR_PER%" \
"Current brightness is $cur_per%" \
-r 100 \
-i $DIR_ICONS/moon.svg
-i "$dir_icons"/moon.svg
fi
+21 -21
View File
@@ -1,44 +1,44 @@
#!/bin/bash
#!/bin/sh
DIR="/usr/local/bin/icons"
dir="/usr/local/bin/icons"
CUR_VOL=$(pactl list sinks | grep '^[[:space:]]Volume:' | \
head -n $(( $SINK + 1 )) | tail -n 1 | sed -e 's,.* \([0-9][0-9]*\)%.*,\1,')
MUTE=$(pactl list sinks | grep Mute | sed 's/.*Mute: //g' | sed 1q)
cur_vol=$(pactl list sinks | grep '^[[:space:]]Volume:' | \
head -n $(( SINK + 1 )) | tail -n 1 | sed -e 's,.* \([0-9][0-9]*\)%.*,\1,')
MUTE=$(pacmd list-sinks | awk '/muted/ { print $2 }' | head -1)
affirmative="yes"
negative="no"
VOL_QUIET=33
VOL_LOUD=66
vol_quiet=33
vol_loud=66
if [[ $MUTE = $affirmative ]]; then
if [ "$MUTE" = "$affirmative" ]; then
dunstify -a "Mute" \
"Mute" \
"Muted" \
"Sink is now muted" \
-r 100 \
-i $DIR/volume-x.svg
elif [[ $MUTE = $negative ]]; then
if [ $CUR_VOL -le $VOL_QUIET ]; then
-i "$dir"/volume-x.svg
elif [ "$MUTE" = "$negative" ]; then
if [ "$cur_vol" -le "$vol_quiet" ]; then
dunstify -a "Mute" \
"Mute" \
"Unmuted" \
"Sink is now unmuted" \
-r 100 \
-i $DIR/volume.svg
-i "$dir"/volume.svg
fi
if [ $CUR_VOL -gt $VOL_QUIET ] && [ $CUR_VOL -le $VOL_LOUD ]; then
if [ "$cur_vol" -gt "$vol_quiet" ] && [ "$cur_vol" -le "$vol_loud" ]; then
dunstify -a "Mute" \
"Mute" \
"Unmuted" \
"Sink is now unmuted" \
-r 100 \
-i $DIR/volume-1.svg
-i "$dir"/volume-1.svg
fi
if [ $CUR_VOL -gt $VOL_LOUD ]; then
if [ "$cur_vol" -gt "$vol_loud" ]; then
dunstify -a "Mute" \
"Mute" \
"Unmuted" \
"Sink is now unmuted" \
-r 100 \
-i $DIR/volume-2.svg
-i "$dir"/volume-2.svg
fi
fi
echo $MUTE
echo "$MUTE"
+2 -2
View File
@@ -1,10 +1,10 @@
#!/usr/bin/env bash
#!/bin/sh
# take all the cache and remove useless packages
sudo pacman -Sc
sudo pacman -Scc
paccache -r
sudo pacman -Rns $(pacman -Qtdq)
sudo pacman -Rns "$(pacman -Qtdq)"
# list cache
sudo du -sh ~/.cache/
+32 -32
View File
@@ -1,73 +1,73 @@
#!/usr/bin/env bash
# rofi theme
THEME="$HOME/.config/rofi/compact_without_icons.rasi"
theme="$HOME/.config/rofi/compact_without_icons.rasi"
get_options() {
echo " Capture Region"
echo " Capture Region (without saving)"
echo " Capture Screen"
echo " Capture Screen (without saving)"
echo " Record Region (GIF)"
echo " Record Screen (GIF)"
echo " Record Region (MP4)"
echo " Record Screen (MP4)"
#echo " Record Region (MP4+audio_virt)"
#echo " Record Region (MP4+audio_mic)"
#echo " Record Audio virt"
#echo " Record Audio mic"
echo " Stop Recording"
echo " Capture Region"
echo " Capture Region (without saving)"
echo " Capture Screen"
echo " Capture Screen (without saving)"
echo " Record Region (GIF)"
echo " Record Screen (GIF)"
echo " Record Region (MP4)"
echo " Record Screen (MP4)"
#echo " Record Region (MP4+audio_virt)"
#echo " Record Region (MP4+audio_mic)"
#echo " Record Audio virt"
#echo " Record Audio mic"
echo " Stop Recording"
}
main() {
# Get choice from rofi
CHOICE=$( (get_options) | rofi -dmenu -i -fuzzy -p "" -theme "$THEME")
# get choice from rofi
choice=$( (get_options) | rofi -dmenu -i -fuzzy -p "" -theme "$theme")
# If user has not picked anything, exit
if [[ -z "${CHOICE// /}" ]]; then
# if user has not picked anything, exit
if [[ -z "${choice// /}" ]]; then
exit 1
fi
# run the selected command
case $CHOICE in
' Capture Region (without saving)')
case $choice in
' Capture Region (without saving)')
screenshot -crtc
;;
' Capture Region')
' Capture Region')
screenshot -crtf
;;
' Capture Screen (without saving)')
' Capture Screen (without saving)')
screenshot -cstc
;;
' Capture Screen')
' Capture Screen')
screenshot -cstf
;;
' Record Region (GIF)')
' Record Region (GIF)')
screenshot -rrg
;;
' Record Screen (GIF)')
' Record Screen (GIF)')
screenshot -rsg
;;
' Record Region (MP4)')
' Record Region (MP4)')
screenshot -rrv
;;
' Record Screen (MP4)')
' Record Screen (MP4)')
screenshot -rsv
;;
' Record Region (MP4+audio_virt)')
' Record Region (MP4+audio_virt)')
screenshot -rrav
;;
' Record Region (MP4+audio_mic)')
' Record Region (MP4+audio_mic)')
screenshot -rrmv
;;
' Record Audio virt')
' Record Audio virt')
screenshot -rav
;;
' Record Audio mic')
' Record Audio mic')
screenshot -ram
;;
' Stop Recording')
' Stop Recording')
screenshot -s
;;
esac
+43 -43
View File
@@ -1,9 +1,9 @@
#!/usr/bin/env bash
#!/bin/sh
# Screenshot directory
SCREENSHOT_DIRECTORY="$HOME/Pictures/screenshots"
VIDEOS_DIRECTORY="$HOME/Videos"
AUDIO_DIRECTORY="$HOME/Music"
# screenshot directory
screenshot_directory="$HOME/Pictures/screenshots"
videos_directory="$HOME/Videos"
audio_directory="$HOME/Music"
# set ffmpeg defaults
ffmpeg() {
@@ -27,7 +27,7 @@ countdown() {
# capture region to clipboard
crtc() {
notify-send "Screenshot" "Select a region to capture"
ffcast -q $(slop -n -f '-g %g ') png /tmp/screenshot_clip.png
ffcast -q "$(slop -n -f '-g %g ')" png /tmp/screenshot_clip.png
xclip -selection clipboard -t image/png /tmp/screenshot_clip.png
rm /tmp/screenshot_clip.png
notify-send "Screenshot" "Region copied to Clipboard"
@@ -36,10 +36,10 @@ crtc() {
# capture region to file and clipboard
crtf() {
notify-send "Screenshot" "Select a region to capture"
DT=$(date '+%d-%m-%Y %H:%M:%S')
ffcast -q $(slop -n -f '-g %g ') png "$SCREENSHOT_DIRECTORY/$DT.png"
xclip -selection clipboard -t image/png "$SCREENSHOT_DIRECTORY/$DT.png"
notify-send "Screenshot" "Region saved to $SCREENSHOT_DIRECTORY"
dt=$(date '+%d-%m-%Y %H:%M:%S')
ffcast -q "$(slop -n -f '-g %g ')" png "$screenshot_directory/$dt.png"
xclip -selection clipboard -t image/png "$screenshot_directory/$dt.png"
notify-send "Screenshot" "Region saved to $screenshot_directory"
}
# capture screenshot to clipboard
@@ -52,96 +52,96 @@ cstc() {
# capture screenshot to file and clipboard
cstf() {
DT=$(date '+%d-%m-%Y %H:%M:%S')
ffcast -q png "$SCREENSHOT_DIRECTORY/$DT.png"
xclip -selection clipboard -t image/png "$SCREENSHOT_DIRECTORY/$DT.png"
notify-send "Screenshot" "Screenshot saved to $SCREENSHOT_DIRECTORY"
dt=$(date '+%d-%m-%Y %H:%M:%S')
ffcast -q png "$screenshot_directory/$dt.png"
xclip -selection clipboard -t image/png "$screenshot_directory/$dt.png"
notify-send "Screenshot" "Screenshot saved to $screenshot_directory"
}
# record region (GIF)
rrg() {
notify-send "Screenshot" "Select a region to record"
DT=$(date '+%d-%m-%Y %H:%M:%S')
ffcast -q $(slop -n -f '-g %g ' && countdown) rec /tmp/screenshot_gif.mp4
dt=$(date '+%d-%m-%Y %H:%M:%S')
ffcast -q "$(slop -n -f '-g %g ' && countdown)" rec /tmp/screenshot_gif.mp4
notify-send "Screenshot" "Converting to gif... (this can take a while)"
video_to_gif /tmp/screenshot_gif.mp4 "$SCREENSHOT_DIRECTORY/$DT.gif"
video_to_gif /tmp/screenshot_gif.mp4 "$screenshot_directory/$dt.gif"
rm /tmp/screenshot_gif.mp4
notify-send "Screenshot" "Recording saved to $SCREENSHOT_DIRECTORY"
notify-send "Screenshot" "Recording saved to $screenshot_directory"
}
# record screen (GIF)
rsg() {
countdown
DT=$(date '+%d-%m-%Y %H:%M:%S')
dt=$(date '+%d-%m-%Y %H:%M:%S')
ffcast -q rec /tmp/screenshot_gif.mp4
notify-send "Screenshot" "Converting to gif... (this can take a while)"
video_to_gif /tmp/screenshot_gif.mp4 "$SCREENSHOT_DIRECTORY/$DT.gif"
video_to_gif /tmp/screenshot_gif.mp4 "$screenshot_directory/$dt.gif"
rm /tmp/screenshot_gif.mp4
notify-send "Screenshot" "Recording saved to $SCREENSHOT_DIRECTORY"
notify-send "Screenshot" "Recording saved to $screenshot_directory"
}
# record region (mp4)
rrv() {
notify-send "Screenshot" "Select a region to record"
DT=$(date '+%d-%m-%Y %H:%M:%S')
ffcast -q $(slop -n -f '-g %g ' && countdown) rec "$VIDEOS_DIRECTORY/$DT.mp4"
notify-send "Screenshot" "Recording saved to $VIDEOS_DIRECTORY"
dt=$(date '+%d-%m-%Y %H:%M:%S')
ffcast -q "$(slop -n -f '-g %g ' && countdown)" rec "$videos_directory/$dt.mp4"
notify-send "Screenshot" "Recording saved to $videos_directory"
}
# record screen (mp4)
rsv() {
countdown
DT=$(date '+%d-%m-%Y %H:%M:%S')
ffcast -q rec "$VIDEOS_DIRECTORY/$DT.mp4"
notify-send "Screenshot" "Recording saved to $VIDEOS_DIRECTORY"
dt=$(date '+%d-%m-%Y %H:%M:%S')
ffcast -q rec "$videos_directory/$dt.mp4"
notify-send "Screenshot" "Recording saved to $videos_directory"
}
# record screen (mp4) with audio virt
rrav() {
notify-send "Screenshot" "Select a region to record"
DT=$(date '+%d-%m-%Y %H:%M:%S')
ffcast -q $(slop -n -f '-g %g ' && countdown) ffmpeg \
dt=$(date '+%d-%m-%Y %H:%M:%S')
ffcast -q "$(slop -n -f '-g %g ' && countdown)" ffmpeg \
-hide_banner \
-loglevel error \
-f x11grab -show_region 1 -framerate 30 -video_size %wx%h -i :0.0+%x,%y \
-f pulse -i alsa_output.pci-0000_00_1f.3.analog-stereo.monitor -ac 1 "$VIDEOS_DIRECTORY/$DT.mp4"
notify-send "Screenshot" "Recording saved to $VIDEOS_DIRECTORY"
-f pulse -i alsa_output.pci-0000_00_1f.3.analog-stereo.monitor -ac 1 "$videos_directory/$dt.mp4"
notify-send "Screenshot" "Recording saved to $videos_directory"
}
# record screen (mp4) with mic audio
rrmv() {
notify-send "Screenshot" "Select a region to record"
DT=$(date '+%d-%m-%Y %H:%M:%S')
ffcast -q $(slop -n -f '-g %g ' && countdown) ffmpeg \
dt=$(date '+%d-%m-%Y %H:%M:%S')
ffcast -q "$(slop -n -f '-g %g ' && countdown)" ffmpeg \
-hide_banner \
-loglevel error \
-f x11grab -show_region 1 -framerate 30 -video_size %wx%h -i :0.0+%x,%y \
-f pulse -i alsa_input.pci-0000_00_1f.3.analog-stereo -ac 1 "$VIDEOS_DIRECTORY/$DT.mp4"
notify-send "Screenshot" "Recording saved to $VIDEOS_DIRECTORY"
-f pulse -i alsa_input.pci-0000_00_1f.3.analog-stereo -ac 1 "$videos_directory/$dt.mp4"
notify-send "Screenshot" "Recording saved to $videos_directory"
}
# record audio virt
rav() {
notify-send "Screenshot" "Starting audio recording." -i sound-recorder
DT=$(date '+%d-%m-%Y %H:%M:%S')
dt=$(date '+%d-%m-%Y %H:%M:%S')
'ffmpeg' \
-loglevel error \
-f pulse -i alsa_output.pci-0000_00_1f.3.analog-stereo.monitor -ac 1 "$AUDIO_DIRECTORY/$DT.mp3"
notify-send "Screenshot" "Audio saved to $AUDIO_DIRECTORY" -i sound-recorder
-f pulse -i alsa_output.pci-0000_00_1f.3.analog-stereo.monitor -ac 1 "$audio_directory/$dt.mp3"
notify-send "Screenshot" "Audio saved to $audio_directory" -i sound-recorder
}
# record audio mic
ram() {
notify-send "Screenshot" "Starting audio recording." -i sound-recorder
DT=$(date '+%d-%m-%Y %H:%M:%S')
dt=$(date '+%d-%m-%Y %H:%M:%S')
'ffmpeg' \
-loglevel error \
-f pulse -i alsa_input.pci-0000_00_1f.3.analog-stereo -ac 1 "$AUDIO_DIRECTORY/$DT.mp3"
notify-send "Screenshot" "Audio saved to $AUDIO_DIRECTORY" -i sound-recorder
-f pulse -i alsa_input.pci-0000_00_1f.3.analog-stereo -ac 1 "$audio_directory/$dt.mp3"
notify-send "Screenshot" "Audio saved to $audio_directory" -i sound-recorder
}
check_deps() {
if ! hash $1 2>/dev/null; then
if ! hash "$1" 2>/dev/null; then
echo "Error: This script requires $1"
exit 1
fi
@@ -249,5 +249,5 @@ main() {
}
# running the program
main $1 &
main "$1" &
exit 0
+5 -5
View File
@@ -1,7 +1,7 @@
#!/usr/bin/env bash
# rofi theme
DIR_THEME="$HOME/.config/rofi/compact_without_icons.rasi"
dir_theme="$HOME/.config/rofi/compact_without_icons.rasi"
DIR="/usr/local/bin/themes"
@@ -12,14 +12,14 @@ get_options_theme_polybar() {
main() {
# Get THEME_POLYBAR from rofi
THEME_POLYBAR=$( (get_options_theme_polybar) | rofi -dmenu -i -fuzzy -p "" -theme "$DIR_THEME")
# Get theme_polybar from rofi
theme_polybar=$( (get_options_theme_polybar) | rofi -dmenu -i -fuzzy -p "" -theme "$dir_theme")
# If user has not picked anything, exit
if [[ -z "${THEME_POLYBAR// /}" ]]; then
if [[ -z "${theme_polybar// /}" ]]; then
exit 1
fi
cp -f $DIR/$THEME_POLYBAR/launch.sh ~/.config/polybar
cp -f $DIR/$theme_polybar/launch.sh ~/.config/polybar
# done
set -e
+15 -15
View File
@@ -1,31 +1,31 @@
#!/bin/bash
#!/bin/sh
DIR_ICONS="/usr/local/bin/icons"
dir_icons="/usr/local/bin/icons"
CUR_VOL=$(pactl list sinks | grep '^[[:space:]]Volume:' | \
head -n $(( $SINK + 1 )) | tail -n 1 | sed -e 's,.* \([0-9][0-9]*\)%.*,\1,')
cur_vol=$(pactl list sinks | grep '^[[:space:]]Volume:' | \
head -n $(( "$SINK" + 1 )) | tail -n 1 | sed -e 's,.* \([0-9][0-9]*\)%.*,\1,')
VOL_QUIET=33
VOL_LOUD=66
vol_quiet=33
vol_loud=66
if [ $CUR_VOL -le $VOL_QUIET ]; then
if [ "$cur_vol" -le "$vol_quiet" ]; then
dunstify -a "Volume" \
"Volume" \
"Current volume is $CUR_VOL%" \
"Current volume is $cur_vol%" \
-r 100 \
-i $DIR_ICONS/volume.svg
-i $dir_icons/volume.svg
fi
if [ $CUR_VOL -gt $VOL_QUIET ] && [ $CUR_VOL -le $VOL_LOUD ]; then
if [ "$cur_vol" -gt "$vol_quiet" ] && [ "$cur_vol" -le "$vol_loud" ]; then
dunstify -a "Volume" \
"Volume" \
"Current volume is $CUR_VOL%" \
"Current volume is $cur_vol%" \
-r 100 \
-i $DIR_ICONS/volume-1.svg
-i $dir_icons/volume-1.svg
fi
if [ $CUR_VOL -gt $VOL_LOUD ]; then
if [ "$cur_vol" -gt "$vol_loud" ]; then
dunstify -a "Volume" \
"Volume" \
"Current volume is $CUR_VOL%" \
"Current volume is $cur_vol%" \
-r 100 \
-i $DIR_ICONS/volume-2.svg
-i $dir_icons/volume-2.svg
fi