fresh init

This commit is contained in:
sankalp committed 2023-05-25 01:05:57 +05:45
1 parent f208f22443
commit 30c3ff48a5
10 files changed
+1333

No files matched your search

+50
View File
@@ -0,0 +1,50 @@
#!/bin/bash
icon_dir="$HOME/.config/bspwm/assets/icons"
steps=5
send_notification () {
brightness=$(brightnessctl i | grep -oP '\(\K[^%\)]+')
if [ $brightness -lt "15" ]; then
icon="$icon_dir/brightness-1.svg"
elif [ $brightness -lt "30" ]; then
icon="$icon_dir/brightness-2.svg"
elif [ $brightness -lt "45" ]; then
icon="$icon_dir/brightness-3.svg"
elif [ $brightness -lt "60" ]; then
icon="$icon_dir/brightness-4.svg"
elif [ $brightness -lt "75" ]; then
icon="$icon_dir/brightness-5.svg"
elif [ $brightness -lt "90" ]; then
icon="$icon_dir/brightness-6.svg"
else
icon="$icon_dir/brightness-7.svg"
fi
notify-send -a Brightness -i $icon -t 2000 -r 969696 "Brightness : $brightness"
}
docs () {
echo "
Usage: brightness [Options]
Options:
up - Increase the brightness
down - Decrease the brightness
"
}
case $1 in
up)
brightnessctl set "${steps:-5}%+" -q
send_notification
;;
down)
brightnessctl set "${steps:-5}%-" -q
send_notification
;;
*)
docs
;;
esac
+16
View File
@@ -0,0 +1,16 @@
#!/usr/bin/env bash
## Simple Script To Pick Color Quickly.
color=$(gpick -pso --no-newline)
main() {
if [[ "$color" ]]; then
# copy color code to clipboard
echo $color | tr -d "\n" | xclip -selection clipboard
# notify about it
dunstify -u low --replace=69 -i /usr/share/archcraft/icons/dunst/dropper.png "$color, copied to clipboard."
fi
}
# Run the script
main
+27
View File
@@ -0,0 +1,27 @@
#!/usr/bin/env bash
#By: S4NKALP https://github.com/S4NKALP
FILE="$HOME/.cache/eww.control"
ewwcfg="$HOME/.config/bspwm/widgets/control-panel"
EWW=`which eww`
if [[ ! `pidof eww` ]]; then
${EWW} -c $HOME/.config/bspwm/widgets/control-panel daemon &
sleep 1
fi
launch_eww() {
${EWW} --config "$ewwcfg" open control-panel
}
## Launch or close widgets accordingly
if [[ ! -f "$FILE" ]]; then
touch "$FILE"
launch_eww
else
${EWW} --config "$ewwcfg" close control-panel
rm "$FILE"
fi
+27
View File
@@ -0,0 +1,27 @@
#!/usr/bin/env bash
#By: S4NKALP https://github.com/S4NKALP
FILE="$HOME/.cache/eww.panel"
ewwcfg="$HOME/.config/bspwm/widgets/info-panel"
EWW=`which eww`
if [[ ! `pidof eww` ]]; then
${EWW} -c $HOME/.config/bspwm/widgets/info-panel daemon &
sleep 1
fi
launch_eww() {
${EWW} --config "$ewwcfg" open info-panel
}
## Launch or close widgets accordingly
if [[ ! -f "$FILE" ]]; then
touch "$FILE"
launch_eww
else
${EWW} --config "$ewwcfg" close info-panel
rm "$FILE"
fi
+130
View File
@@ -0,0 +1,130 @@
#!/bin/bash
cache_dir="$HOME/.cache/eww"
cache="$cache_dir/notifications.txt"
[ ! -d $cache_dir ] && mkdir $cache_dir
[ ! -f $cache ] && touch $cache
create_cache () {
case $DUNST_URGENCY in
LOW|NORMAL|CRITICAL)
urgency=$DUNST_URGENCY
;;
*)
urgency="OTHER"
;;
esac
TIMESTAMP=$(date +%H:%M)
[ "$DUNST_SUMMARY" = "" ] && summary="Summary unavailable." || summary="$DUNST_SUMMARY"
[ "$DUNST_BODY" = "" ] && body="Body unavailable." || body="$(printf "$DUNST_BODY" | perl -MHTML::Entities -pe 'decode_entities($_);')"
# TODO: Getting and caching web notification icons (dunstctl history won't show the icon path :()
if [[ $DUNST_ICON_PATH == "" ]]; then
APP_NAME=$(echo $DUNST_APP_NAME | awk '{print tolower($0)}')
ICON_PATH=/usr/share/icons/Papirus/128x128/apps/$APP_NAME.svg
else
FIXED_ICON_PATH=$(echo ${DUNST_ICON_PATH} | sed 's/32x32/48x48/g')
ICON_PATH=$FIXED_ICON_PATH
fi
# If you have a mpris player that send notification you can add one here just follow the layout
if [[ $DUNST_APP_NAME == "Spotify" ]]; then
ICON_PATH=$(~./config/bspwm/scripts/music cover-notification spotify)
fi
if [[ $DUNST_APP_NAME == "Music Player Daemon" ]]; then
if [[ $DUNST_BODY =~ "by" ]]; then
ICON_PATH=$(~./config/bspwm/scripts/music cover-notification mpd)
else
ICON_PATH=/usr/share/icons/Papirus/128x128/apps/mpd.svg
fi
fi
if [[ $DUNST_APP_NAME == "Screenshot" ]]; then
echo '(notification-card-screenshot :class "notification-card $notification-card-screenshot" :U "LOW" :SL "'$DUNST_ID'" :summary "'$summary'" :image "'$ICON_PATH'" :application "'$DUNST_APP_NAME'" :timestamp "'$TIMESTAMP'")' \
| cat - "$cache" \
| sponge "$cache"
elif [[ $DUNST_APP_NAME == "Volume" ]]; then
echo 'Null' # This is still a work in progress, for now this will be ignored by the notification-panel (Also you can follow the layout if you want to add ignore notifications)
elif [[ $DUNST_APP_NAME == "Brightness" ]]; then
echo 'Null'
else
echo '(notification-card :class "notification-card notification-card-'$DUNST_APP_NAME'" :U "'$DUNST_URGENCY'" :SL "'$DUNST_ID'" :body "'$body'" :summary "'$summary'" :image "'$ICON_PATH'" :application "'$DUNST_APP_NAME'" :timestamp "'$TIMESTAMP'")' \
| cat - "$cache" \
| sponge "$cache"
fi
}
make_literal () {
caches="$(tr '\n' ' ' < "$cache")"
if [[ "$caches" == "" ]]; then
echo '(box :class "notifications-empty-box" :height 550 :orientation "v" :space-evenly "false" (image :class "notifications-empty-banner" :valign "end" :vexpand true :path "~/.config/bspwm/assets/icons/notifications-off.svg" :image-width 300 :image-height 200) (label :vexpand true :valign "start" :wrap true :class "notifications-empty-label" :text "No Notifications"))'
else
echo "(scroll :height 550 :vscroll true (box :orientation 'v' :class 'notification-scroll-box' :spacing 10 :space-evenly 'false' $caches))"
fi
}
clear_logs () {
killall dunst 2>/dev/null
dunst -config $HOME/.config/dunst/dunstrc &
echo > "$cache"
rm -rf $HOME/.cache/eww/music/notification-cover/*.png
}
subscribe () {
make_literal
lines=$(cat $cache | wc -l)
while sleep 0.1; do
new=$(cat $cache | wc -l)
[[ $lines -ne $new ]] && lines=$new && echo
done | read_literal
}
read_literal () {
while read -r _; do
make_literal
done
}
remove_line () {
sed -i '/SL "'$1'"/d' "$cache"
}
case $1 in
pop)
sed -i '1d' "$cache"
;;
drop)
sed -i '$d' "$cache"
;;
remove)
remove_line $2
;;
clear)
clear_logs
;;
subscribe)
subscribe
;;
criticals)
printf '%03d\n' $(cat $cache | grep CRITICAL | wc --lines)
;;
lows)
printf '%03d\n' $(cat $cache | grep LOW | wc --lines)
;;
normals)
printf '%03d\n' $(cat $cache | grep NORMAL | wc --lines)
;;
*)
create_cache
;;
esac
sed -i '/^$/d' "$cache"
+175
View File
@@ -0,0 +1,175 @@
#!/bin/bash
rofi_command="rofi -theme"
time=$(date +%Y-%m-%d-%H-%M-%S)
geometry=$(xrandr | head -n1 | cut -d',' -f2 | tr -d '[:blank:],current')
dir="$(xdg-user-dir VIDEOS)/Screenrecords"
file="Capture_$time.mp4"
timer_icon="$HOME/.config/bspwm/assets/icons/timer.svg"
[ ! -d $dir ] && mkdir -p $dir
notify_user () {
if [[ -e $dir/$file ]]; then
notify-send -u low -a Screenrecorder "Saved in $dir"
else
notify-send -u -a Screenrecorder -i ~/.config/bspwm/assets/icons/cancel.svg "Video Deleted"
fi
}
countdown () {
for sec in `seq $1 -1 1`; do
notify-send -u low -a Clock -i $timer_icon -t 1000 "Countdown" "Starting in : $sec"
sleep 1
done
}
capture () {
countdown '3'
sleep 1
if [[ $1 == "noaudio" ]]; then
ffmpeg -video_size $geometry -framerate 25 -f x11grab -i :0.0+0,0 $dir/$file
else
ffmpeg -video_size $geometry -framerate 25 -f x11grab -i :0.0+0,0 -f pulse -ac 2 -i default $dir/$file
fi
notify_user
}
capture_area () {
area_data=$(slop -f "%x %y %w %h %g %i") || exit 1
read -r X Y W H G ID < <(echo $area_data)
countdown '3'
sleep 1
if [[ $1 == "noaudio" ]]; then
ffmpeg -video_size ${W}x${H} -framerate 25 -f x11grab -i :0.0+${X},${Y} $dir/$file
else
ffmpeg -video_size ${W}x${H} -framerate 25 -f x11grab -i :0.0+${X},${Y} -f pulse -ac 2 -i default $dir/$file
fi
notify_user
}
capture_timer () {
confirm=$($HOME/.config/rofi/bin/confirm 'Set a number')
confirm_config="$HOME/.config/rofi/rasi/confirm.rasi"
if [[ $confirm =~ ^[0-9]+$ ]]; then
countdown $confirm
if [[ $1 == "noaudio" ]]; then
ffmpeg -video_size $geometry -framerate 25 -f x11grab -i :0.0+0,0 $dir/$file
else
ffmpeg -f x11grab -r 30 -s $(xdpyinfo | grep dimensions | awk '{print $2;}') -i :0.0 -f pulse -i alsa_output.pci-0000_00_1f.3.analog-stereo.monitor $dir/$file
fi
notify_user
else
$rofi_command $confirm_config -e "Please input a Number"
fi
}
capture_rofi () {
config="$HOME/.config/rofi/rasi/screenutils.rasi"
capture="󰇄"
area="󰊓"
timer="󰔛"
stop=""
withaudio="󰕾"
withoutaudio="󰖁"
options="$capture\n$area\n$timer\n$stop"
audio_options="$withaudio\n$withoutaudio"
chosen=$(echo -e $options | $rofi_command $config -p 'Take Screenshot' -dmenu -selected-row 0 -theme-str 'listview {lines: 4;}')
audio_chooser () {
audio_chosen=$(echo -e $audio_options | $rofi_command $config -p 'Choose' -dmenu -selected-row 0 -theme-str 'listview {lines: 2;}')
if [[ $chosen == $capture ]]; then
case $audio_chosen in
$withaudio)
capture
;;
$withoutaudio)
capture noaudio
;;
esac
elif [[ $chosen == $area ]]; then
case $audio_chosen in
$withaudio)
capture_area
;;
$withoutaudio)
capture_area noaudio
;;
esac
elif [[ $chosen == $timer ]]; then
case $audio_chosen in
$withaudio)
capture_timer
;;
$withoutaudio)
capture_timer noaudio
;;
esac
fi
}
case $chosen in
$capture)
audio_chooser
;;
$area)
audio_chooser
;;
$timer)
audio_chooser
;;
$stop)
[ `pidof ffmpeg` ] && pkill ffmpeg
;;
esac
}
docs () {
echo "
Usage: screenrecord [Options]
Options:
capture - Record the desktop
capture-noaudio - Record the desktop without audio
capture-area - Record the selected area
capture-area-noaudio - Record the selected area without audio
capture-timer - Set a custom timer
capture-timer-noaudio - Set a custom timer without audio
capture-rofi - Launcher of recording
capture-stop - Stop the recorder
"
}
case $1 in
capture)
capture
;;
capture-area)
capture_area
;;
capture-noaudio)
capture noaudio
;;
capture-area-noaudio)
capture_area noaudio
;;
capture-timer)
capture_timer
;;
capture-timer-noaudio)
capture_timer noaudio
;;
capture-rofi)
capture_rofi
;;
capture-stop)
[ `pidof ffmpeg` ] && pkill ffmpeg
;;
--help)
docs
;;
esac
+157
View File
@@ -0,0 +1,157 @@
#!/bin/bash
rofi_command="rofi -theme"
time=$(date +%Y-%m-%d-%I-%M-%S)
geometry=$(xrandr | head -n1 | cut -d',' -f2 | tr -d '[:blank:],current')
dir="$(xdg-user-dir PICTURES)/Screenshots"
file="Screenshot_${time}_${geometry}.png"
timer_icon="$HOME/.config/bspwm/assets/icons/timer.svg"
clipboard_icon="$HOME/.config/bspwm/assets/icons/clipboard.svg"
[ ! -d $dir ] && mkdir -p $dir
notify_user () {
notify-send -a Clipboard -i $clipboard_icon -u low -r 699 "Clipboard" "Screenshot saved on clipboard"
if [[ -e $dir/$file ]]; then
notify-send -a Screenshot -u low -i $dir/$file "Screenshot Saved"
else
notify-send -a Screenshot -u low -i ~/.config/bspwm/assets/icons/cancel.svg "Screenshot Deleted"
fi
}
countdown () {
for sec in `seq $1 -1 1`; do
notify-send -a Clock -u normal -t 1000 -i $timer_icon "Countdown" "Taking shot in : $sec"
sleep 1
done
}
magic () {
convert $file +antialias \
\( +clone -alpha extract \
-draw 'fill black polygon 0,0 0,20 20,0 fill white circle 20,20 20,0' \
\( +clone -flip \) -compose Multiply -composite \
\( +clone -flop \) -compose Multiply -composite \
\) -alpha off -compose CopyOpacity -composite $file
convert $file \
\( +clone -background black -shadow 69x20+0+10 \) \
+swap -background none -layers merge +repage $file
}
shot () {
cd $dir && maim -u -f png $file && magic && xclip -selection clipboard -t image/png -i $file
notify_user
}
shot_window () {
cd $dir && maim -u -f png -i `xdotool getactivewindow` $file && magic && xclip -selection clipboard -t image/png -i $file
notify_user
}
shot_area () {
cd $dir && maim -u -f png -s -b 2 -c 0.35,0.55,0.85,0.25 -l $file && magic && xclip -selection clipboard -t image/png -i $file
notify_user
}
shot_3 () {
countdown '3'
sleep 1 && cd $dir && maim -u -f png $file && magic && xclip -selection clipboard -t image/png -i $file
notify_user
}
shot_10 () {
countdown '10'
sleep 1 && cd $dir && maim -u -f png $file && magic && xclip -selection clipboard -t image/png -i $file
notify_user
}
shot_timer () {
confirm=$($HOME/.config/rofi/bin/confirm 'Set a number')
confirm_config="$HOME/.config/rofi/rasi/confirm.rasi"
if [[ $confirm =~ ^[0-9]+$ ]]; then
countdown $confirm
sleep 1 && cd $dir && maim -u -f png $file && magic && xclip -selection clipboard -t image/png -i $file
notify_user
else
$rofi_command $confirm_config -e "Please input a Number"
exit
fi
}
shot_rofi () {
config="$HOME/.config/rofi/rasi/screenutils.rasi"
screen=""
area=""
window=""
inthree=""
inten=""
timer=""
options="$screen\n$area\n$window\n$inthree\n$inten\n$timer"
chosen="$(echo -e "$options" | $rofi_command $config -p 'Take Screenshot' -dmenu -selected-row 0 -theme-str 'listview {lines: 6;}')"
case $chosen in
$screen)
shot
;;
$area)
shot_area
;;
$window)
shot_window
;;
$inthree)
shot_3
;;
$inten)
shot_10
;;
$timer)
shot_timer
;;
esac
}
docs () {
echo "
Usage: screenshot [Options]
Options:
now - Take screenshot of the desktop
window - Take screenshot of the focused window
area - Take screenshot of the selected area
in5 - Take screenshot in 5 seconds
in10 - Take screenshot in 10 seconds
timer - Set a custom timer
"
}
case $1 in
shot-screen)
shot
;;
shot-window)
shot_window
;;
shot-area)
shot_area
;;
shot-in3)
shot_3
;;
shot-in10)
shot_10
;;
shot-rofi)
shot_rofi
;;
shot-timer)
shot_timer
;;
--help)
docs
;;
esac
+27
View File
@@ -0,0 +1,27 @@
#!/usr/bin/env bash
#By: S4NKALP https://github.com/S4NKALP
FILE="$HOME/.cache/eww.sidebar"
ewwcfg="$HOME/.config/bspwm/widgets/sidebar"
EWW=`which eww`
if [[ ! `pidof eww` ]]; then
${EWW} -c $HOME/.config/bspwm/widgets/sidebar daemon &
sleep 1
fi
launch_eww() {
${EWW} --config "$ewwcfg" open dashboard
}
## Launch or close widgets accordingly
if [[ ! -f "$FILE" ]]; then
touch "$FILE"
launch_eww
else
${EWW} --config "$ewwcfg" close dashboard
rm "$FILE"
fi
+50
View File
@@ -0,0 +1,50 @@
#!/bin/bash
icon_dir="$HOME/.config/bspwm/assets/icons"
send_notification () {
volume=$(pamixer --get-volume)
if [[ "$volume" -lt "35" ]]; then
icon="$icon_dir/volume-down.svg"
elif [[ "$volume" -lt "70" ]]; then
icon="$icon_dir/volume-medium.svg"
else
icon="$icon_dir/volume-up.svg"
fi
notify-send -a "Volume" -u normal -i $icon -r 696969 "Volume : $volume"
}
docs () {
echo "
Usage: volume [Options]
Options:
up - Increase the volume
down - Decrease the volume
mute - Mute the volume
"
}
case $1 in
up)
pamixer -i 5 --set-limit 100
send_notification
;;
down)
pamixer -d 5 --set-limit 100
send_notification
;;
mute)
pamixer -t
if [[ $(pamixer --get-mute) = "true" ]]; then
icon="$icon_dir/volume-mute.svg"
notify-send -a Volume -i $icon -r 699 "Volume : Muted"
else
send_notification
fi
;;
*)
docs
;;
esac