Skip to content

Commit 6334f4c

Browse files
committed
old and new scripts update
0 parents  commit 6334f4c

21 files changed

+513
-0
lines changed

battery-notify

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/usr/bin/env bash
2+
3+
export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus
4+
battery=$(upower -i /org/freedesktop/UPower/devices/battery_BAT0 | grep "percentage:" | awk '{ print $2 }' | tr -d '%')
5+
state=$(upower -i /org/freedesktop/UPower/devices/battery_BAT0 | grep "state:" | awk '{ print $2 }')
6+
lower_limit=20
7+
upper_limit=96
8+
9+
if [ "$battery" -lt "$lower_limit" ]; then
10+
if [ "$state" != "charging" ]; then
11+
DISPLAY=:0 /usr/bin/notify-send --urgency=critical "Battery below 20%"
12+
fi
13+
elif [ "$battery" -gt "$upper_limit" ]; then
14+
if [ "$state" == "charging" ]; then
15+
DISPLAY=:0 /usr/bin/notify-send --urgency=low "Charged up almost 100%"
16+
fi
17+
fi

brightness.sh

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/usr/bin/env bash
2+
3+
TRIGGER=$1
4+
MAX=$(cat /sys/class/backlight/amdgpu_bl0/max_brightness)
5+
ACTUAL=$(cat /sys/class/backlight/amdgpu_bl0/actual_brightness)
6+
7+
brightnessicon="$HOME/.local/share/icons/custom/brightness.svg"
8+
9+
if [ $TRIGGER -eq 0 ]; then
10+
if [ $ACTUAL -gt 0 ]; then
11+
VAL=$(brightnessctl set 1- | grep Current | awk -F '[()%]' '{print $2}')
12+
else
13+
VAL=0
14+
fi
15+
elif [ $TRIGGER -eq 1 ]; then
16+
if [ $ACTUAL -lt $MAX ]; then
17+
VAL=$(brightnessctl set 1+ | grep Current | awk -F '[()%]' '{print $2}')
18+
else
19+
VAL=100
20+
fi
21+
fi
22+
23+
dunstify "$VAL%" -i $brightnessicon -r 9991 -t 1000 -h int:value:$VAL

charge.sh

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/usr/bin/env bash
2+
3+
CHARGING=$1
4+
BATTERY=$(acpi -b | grep -P -o '[0-9]+(?=%)')
5+
6+
export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus
7+
8+
if [ "$CHARGING" -eq 1 ]; then
9+
DISPLAY=:0 /usr/bin/notify-send "Connected" "${BATTERY}% battery charging" -u normal -i "/home/zuxroy/.local/share/icons/custom/battery-charging.svg" -t 5000 -r 9991
10+
elif [ "$CHARGING" -eq 0 ]; then
11+
DISPLAY=:0 /usr/bin/notify-send "Disconnected" "${BATTERY}% battery discharging" -u normal -i "/home/zuxroy/.local/share/icons/custom/battery-full.svg" -t 5000 -r 9991
12+
else
13+
STATE=$(upower -i /org/freedesktop/UPower/devices/battery_BAT0 | grep "state:" | awk '{ print $2 }')
14+
if [ "$STATE" = "charging" ]; then
15+
DISPLAY=:0 /usr/bin/notify-send "Charging" "${BATTERY}% charge remaining" -u normal -i "/home/zuxroy/.local/share/icons/custom/battery-full.svg" -t 5000 -r 9991
16+
else
17+
DISPLAY=:0 /usr/bin/notify-send "${BATTERY}% charge remaining" -u normal -i "/home/zuxroy/.local/share/icons/custom/battery-full.svg" -t 5000 -r 9991
18+
fi
19+
fi

date-time-noti.sh

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env bash
2+
3+
val=$(date | awk '{printf "%s %s %s\n%s %s\n", $1, $2, $3, $5, $6}')
4+
dunstify "$val" -u normal -t 5000 -r 9991 -i "$HOME/.local/share/icons/custom/calendar-clock.svg"

dmenu-browser-search

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#!/usr/bin/env bash
2+
3+
options=(
4+
"amazon"
5+
"amazon prime music"
6+
"amazon prime videos"
7+
"chat gpt"
8+
"classsroom"
9+
"codeforces"
10+
"discord"
11+
"github"
12+
"gmail"
13+
"linkedin"
14+
"whatsapp"
15+
"youtube"
16+
)
17+
18+
options_urls=(
19+
"https://www.amazon.in/"
20+
"https://music.amazon.in/my/library"
21+
"https://www.primevideo.com/"
22+
"https://chat.openai.com/"
23+
"https://classroom.google.com/u/1/h"
24+
"https://codeforces.com/"
25+
"https://discord.com/channels/@me"
26+
"https://github.com/"
27+
"https://mail.google.com/"
28+
"https://www.linkedin.com/feed/"
29+
"https://web.whatsapp.com/"
30+
"https://www.youtube.com/"
31+
)
32+
33+
url=$(printf "%s\n" "${options[@]}" | dmenu -i -sb purple -p "Search Term " -l 15 -nb black)
34+
35+
if [ -n "$url" ]; then
36+
#OPTIONAL : i3 config to open window in workspace 2
37+
i3-msg "workspace 2"
38+
39+
index=0
40+
flag=0
41+
for search in "${options[@]}"; do
42+
if [ "$search" = "$url" ]; then
43+
url="${options_urls[index]}"
44+
flag=1
45+
break
46+
fi
47+
((index++))
48+
done
49+
50+
if [ "$flag" == 0 ]; then
51+
url="https://www.google.com/search?q=$(echo "$url" | sed 's/ /+/g')"
52+
google-chrome -incognito "$url"
53+
else
54+
google-chrome "$url"
55+
fi
56+
fi

dmenu-edit-history

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/usr/bin/env bash
2+
3+
history_file="$HOME/.vim-history"
4+
mapfile -t file_history < <(tac "$history_file")
5+
6+
selected_file=$(printf "%s\n" "${file_history[@]}" | dmenu -i -nb black -sb purple -l 15 -p "Edit File ")
7+
8+
if [ -z "$selected_file" ]; then
9+
exit 0
10+
fi
11+
12+
if [ -f "$selected_file" ]; then
13+
kitty -e vim "$selected_file"
14+
else
15+
printf "File not found" | dmenu -i -nb black -sb purple -p "Error "
16+
fi

dmenu-file-manager

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/usr/bin/env bash
2+
3+
target="$HOME"
4+
while true ; do
5+
files=()
6+
while IFS= read -r file; do
7+
files+=("$file")
8+
done < <(ls -a "$target")
9+
selection=$(printf "%s\n" "${files[@]}" | dmenu -i -sb purple -nb black -p "File Manager " -l 10)
10+
11+
if [ $? -eq 1 ]; then
12+
exit 0
13+
fi
14+
if [ "$selection" == ".." ]; then
15+
target=$(dirname "$target")
16+
elif [ "$selection" != "." ]; then
17+
target="$target/$selection"
18+
else
19+
kitty -e tmux new-session -c "$target" -d
20+
kitty -e tmux attach-session -t 0
21+
exit 0
22+
fi
23+
if [ ! -d "$target" ]; then
24+
~/scripts/file-handler "$target"
25+
exit 0
26+
fi
27+
done

dmenu-volume-edit

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/usr/bin/env bash
2+
3+
options=("Increase Volume" "Decrease Volume" "Mute/Unmute")
4+
5+
while true; do
6+
volume=$(pactl list sinks | grep 'Volume: ' | head -n 1 | awk '{print $5}')
7+
device=$(pactl list sinks | grep 'Active Port:' | awk '{print $3}' | awk -F- '{print $3}')
8+
9+
if pactl list sinks | grep -q "Mute: yes"; then
10+
options[2]="Unmute"
11+
else
12+
options[2]="Mute"
13+
fi
14+
15+
selected_option=$(printf '%s\n' "${options[@]}" | dmenu -i -nb black -sb purple -p "Volume [$device] : $volume ")
16+
17+
if [ -z "$selected_option" ]; then
18+
exit 0
19+
fi
20+
21+
case $selected_option in
22+
"Increase Volume")
23+
options[0]="Increase Volume"
24+
options[1]="Decrease Volume"
25+
if [ "${volume%"%"}" -lt 100 ]; then
26+
pactl set-sink-volume @DEFAULT_SINK@ +5%
27+
fi
28+
;;
29+
"Decrease Volume")
30+
options[0]="Decrease Volume"
31+
options[1]="Increase Volume"
32+
if [ "${volume%"%"}" -gt 0 ]; then
33+
pactl set-sink-volume @DEFAULT_SINK@ -5%
34+
fi
35+
;;
36+
"Mute" | "Unmute")
37+
pactl set-sink-mute @DEFAULT_SINK@ toggle
38+
exit 0
39+
;;
40+
esac
41+
done
42+

file-handler

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/usr/bin/env bash
2+
3+
filename="$1"
4+
filetype=$(file -b "$filename" | awk '{ print $1 }')
5+
6+
case "$filetype" in
7+
"PNG" | "JPG" | "JPEG" | "GIF" | "SVG" | "ICO" | "WEBP")
8+
feh "$filename"
9+
;;
10+
"MP4" | "WEBM")
11+
mpv "$filename"
12+
;;
13+
"PDF")
14+
zathura "$filename"
15+
;;
16+
"Microsoft")
17+
wps "$filename"
18+
;;
19+
# add for "CIRC" files in logisim which show up as xml
20+
*)
21+
if file -b "$filename" | grep -q "script"; then
22+
choice=$(printf "Yes\nNo" | dmenu -i -sb purple -p "Run this script ? " -nb black)
23+
if [ $? -eq 1 ]; then
24+
exit 0
25+
fi
26+
if [ "$choice" == "Yes" ]; then
27+
"$filename"
28+
else
29+
kitty -e vim $filename
30+
fi
31+
elif file -b "$filename" | grep -q "text"; then
32+
kitty -e vim "$filename"
33+
else
34+
kitty -e "$filename"
35+
fi
36+
esac

fix-wifi.sh

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/usr/bin/env bash
2+
3+
sudo modprobe -r rtw88_8822ce
4+
sleep 1
5+
sudo modprobe -r rtw88_8822c
6+
sleep 1
7+
sudo modprobe -r rtw88_pci
8+
sleep 1
9+
sudo modprobe -r rtw88_core
10+
sleep 1
11+
sudo modprobe rtw88_8822ce
12+
sleep 1
13+
sudo modprobe rtw88_8822c
14+
sleep 1
15+
sudo modprobe rtw88_pci
16+
sleep 1
17+
sudo modprobe rtw88_core
18+
sleep 2
19+
wifi-rofi.sh

fr

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/usr/bin/env bash
2+
# Find a pattern with rg and fzf. Preview contents with bat. Edit File.
3+
#
4+
# Dependencies:
5+
# 1. rg | recursively search current directory for lines matching a pattern
6+
# 2. fzf | command-line fuzzy finder
7+
# 3. bat | a cat clone with syntax highlighting and Git integration
8+
# 4. $EDITOR | Exported environment variable referring to your editor.
9+
#
10+
# Shout Out:
11+
# https://github.com/junegunn/fzf/blob/master/ADVANCED.md#using-fzf-as-interactive-ripgrep-launcher
12+
#
13+
# 1. Search for text in files using Ripgrep
14+
# 2. Interactively restart Ripgrep with reload action
15+
# 3. Open the file in $EDITOR
16+
17+
RG_PREFIX="rg --column --line-number --no-heading --color=always --smart-case "
18+
INITIAL_QUERY="${*:-}"
19+
IFS=: read -ra selected < <(
20+
FZF_DEFAULT_COMMAND="$RG_PREFIX $(printf %q "$INITIAL_QUERY")" \
21+
fzf --ansi \
22+
--disabled --query "$INITIAL_QUERY" \
23+
--bind "change:reload:sleep 0.1; $RG_PREFIX {q} || true" \
24+
--delimiter : \
25+
--preview 'batcat --color=always {1} --highlight-line {2}' \
26+
--preview-window 'right,50%,border-bottom,+{2}+3/3,~3'
27+
)
28+
[ -n "${selected[0]}" ] && $EDITOR "${selected[0]}" "+${selected[1]}"

memory-noti.sh

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env bash
2+
3+
mem=$(free -m | awk '/^Mem:/ {printf "Used Memory \t: %.2f GB\nTotal Memory \t: %.2f GB\n", $2/1024, $3/1024}')
4+
dunstify "$mem" -u normal -t 5000 -r 9991 -i "$HOME/.local/share/icons/custom/memory.svg"

power-menu

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/usr/bin/env bash
2+
3+
choice=$(printf "Shutdown\nReboot" | dmenu -i -p "Power Menu " -nb black -sb purple | awk '{print tolower($0)}')
4+
5+
if [ -n "$choice" ]; then
6+
option=$(printf "Yes\nNo" | dmenu -i -p "$choice ? " -nb black -sb purple)
7+
if [ "$option" == "Yes" ]; then
8+
$choice
9+
fi
10+
fi

power.sh

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/usr/bin/env bash
2+
3+
export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus
4+
battery=$(upower -i /org/freedesktop/UPower/devices/battery_BAT0 | grep "percentage:" | awk '{ print $2 }' | tr -d '%')
5+
state=$(upower -i /org/freedesktop/UPower/devices/battery_BAT0 | grep "state:" | awk '{ print $2 }')
6+
lower_limit=20
7+
upper_limit=96
8+
critical_limit=5
9+
10+
if [ "$battery" -lt "$lower_limit" ]; then
11+
if [ "$state" != "charging" ]; then
12+
DISPLAY=:0 /usr/bin/notify-send --urgency=normal "Battery Low" "Plug in! $battery% charge remaining" -i "/home/zuxroy/.local/share/icons/custom/battery_low.svg" -r 9991
13+
fi
14+
elif [ "$battery" -gt "$upper_limit" ]; then
15+
if [ "$state" == "charging" ]; then
16+
DISPLAY=:0 /usr/bin/notify-send --urgency=normal "Battery Almost Full" "Charged up $battery%" -i "/home/zuxroy/.local/share/icons/custom/battery_full.svg" -r 9991
17+
fi
18+
elif [ "$battery" -lt "$critical_limit" ]; then
19+
if [ "$state" != "charging" ]; then
20+
DISPLAY=:0 /usr/bin/notify-send --urgency=critical "Battery Almost Dead" "Charge immediately! $battery% charge remaining" -i "/home/zuxroy/.local/share/icons/custom/battery_alert.svg" -r 9991
21+
fi
22+
fi

reminder

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env bash
2+
3+
read rem
4+
clear && echo $rem

screenshot-taker

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/usr/bin/env bash
2+
3+
filename=$(scrot -e 'mv $f ~/Pictures & echo $f')
4+
nautilus --no-desktop --select "$HOME/Pictures/$filename"
5+
icon_path="~/Pictures/$filename"
6+
notify-send --urgency=low "Screenshot Saved !" "$icon_path"

screenshot-x11.sh

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/bin/bash
2+
3+
mkdir -p "$HOME/Pictures/Screenshots"
4+
5+
eval $(xdotool getmouselocation --shell)
6+
start_x=$X
7+
start_y=$Y
8+
9+
filename="$HOME/Pictures/Screenshots/screenshot-$(date +"%d-%m-%Y_%H-%M-%S").png"
10+
11+
maim --select --hidecursor > "$filename"
12+
exit_status=$?
13+
14+
if [[ "$exit_status" -ne 0 ]]; then
15+
rm -rf "$filename"
16+
notify-send "Screenshot cancelled" -r 9991 -t 5000 -u low
17+
exit
18+
fi
19+
20+
notify-send "Screenshot saved" -r 9991 -t 5000 -i "$filename"
21+
feh -F "$filename"
22+
23+
choice=$(echo -e "(Y) Yes\n(N) No\n(R) Retake screenshot" | rofi -dmenu -i -p "Copy screenshot ? " -l 3)
24+
25+
if [[ "$choice" = "(Y) Yes" ]]; then
26+
notify-send "Screenshot copied" -r 9991 -t 5000 -i "$HOME/.local/share/icons/custom/clipboard.svg"
27+
cat "$filename" | xclip -selection clipboard -t image/png
28+
elif [[ "$choice" = "(R) Retake screenshot" ]]; then
29+
notify-send "Screenshot deleted" -r 9991 -t 5000 -i "$HOME/.local/share/icons/custom/delete.svg"
30+
rm -rf "$filename"
31+
screenshot-x11.sh
32+
fi

0 commit comments

Comments
 (0)