moved all desktop utils into this repo

This commit is contained in:
willifan 2024-06-03 11:56:16 +02:00
parent cd7e93374e
commit 2241d30a86
28 changed files with 151 additions and 45 deletions

10
ewwScripts/brightness.sh Executable file
View file

@ -0,0 +1,10 @@
#!/usr/bin/env bash
FILE_TO_WATCH="/sys/class/backlight/intel_backlight/brightness" # Replace with the actual file path
cat "$FILE_TO_WATCH"
while true; do
inotifywait -e modify "$FILE_TO_WATCH"
cat "$FILE_TO_WATCH"
done

24
ewwScripts/volume.sh Executable file
View file

@ -0,0 +1,24 @@
#!/usr/bin/env bash
generate() {
message=$(wpctl get-volume @DEFAULT_AUDIO_SINK@)
volume=$(awk '{print $2 * 100}' <<< "$message")
if [[ $(awk '{print $3}' <<< "$message") == "[MUTED]" ]]; then
muted=1
else
muted=0
fi
echo '{"volume":"'"$volume"'","muted":"'"$muted"'"}'
}
generate
pactl subscribe | while read -r event; do
if [[ "$event" == *"Event 'change'"* ]]; then
generate
fi
done

BIN
images/Bob Ross.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 734 KiB

BIN
images/hibernate.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

BIN
images/lock.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.9 KiB

BIN
images/logout.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.2 KiB

BIN
images/reboot.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

BIN
images/shutdown.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

BIN
images/suspend.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

View file

@ -1,10 +1,36 @@
#!/usr/bin/env bash
FILE_TO_WATCH="/sys/class/backlight/intel_backlight/brightness" # Replace with the actual file path
brightness_file="/sys/class/backlight/intel_backlight/brightness"
min_brightness=1
max_brightness=96000
cat "$FILE_TO_WATCH"
# Check if an argument is provided
if [[ -z $1 ]]; then
# echo "Error: Number argument is missing."
exit 1
fi
while true; do
inotifywait -e modify "$FILE_TO_WATCH"
cat "$FILE_TO_WATCH"
done
# Retrieve the argument value
number_to_add=$1
# Validate if the argument is a number
if ! [[ $number_to_add =~ ^-?[0-9]+$ ]]; then
# echo "Error: Invalid number argument."
exit 1
fi
# Read the current brightness value from the file
current_brightness=$(cat "$brightness_file")
# Add the desired number to the current brightness
new_brightness=$((current_brightness + number_to_add))
# Enforce minimum and maximum brightness values
if (( new_brightness < min_brightness )); then
new_brightness=$min_brightness
elif (( new_brightness > max_brightness )); then
new_brightness=$max_brightness
fi
# Write the new brightness value back to the file
echo "$new_brightness" >> "$brightness_file"

8
scripts/clients/.idea/.gitignore generated vendored
View file

@ -1,8 +0,0 @@
# Default ignored files
/shelf/
/workspace.xml
# Editor-based HTTP Client requests
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml

View file

@ -1,2 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<module classpath="CMake" type="CPP_MODULE" version="4" />

View file

@ -1,4 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CMakeWorkspace" PROJECT_DIR="$PROJECT_DIR$" />
</project>

View file

@ -1,8 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/clients.iml" filepath="$PROJECT_DIR$/.idea/clients.iml" />
</modules>
</component>
</project>

7
scripts/idle.sh Executable file
View file

@ -0,0 +1,7 @@
#!/usr/bin/env bash
if [[ $(acpi -a | awk '{print $3}') == "on-line" ]]; then
swaylock
else
systemctl suspend-then-hibernate
fi

7
scripts/lock.sh Executable file
View file

@ -0,0 +1,7 @@
#!/usr/bin/env bash
swaylock &
sleep 0.1
hyprctl dispatch dpms off

10
scripts/scale.sh Executable file
View file

@ -0,0 +1,10 @@
#!/usr/bin/env bash
while read -r f s; do
if [[ $f == true && $(awk -v s="$s" 'BEGIN{ if (s > 1.5) print 1; else print 0; }') == 1 ]]; then
export GDK_SCALE=2
export QT_SCALE_FACTOR=2
fi
done < <(hyprctl monitors -j | jq -r '.[]|"\(.focused) \(.scale)"')
wofi --show drun

0
scripts/startup.sh Normal file
View file

View file

@ -1,24 +1,34 @@
#!/usr/bin/env bash
generate() {
message=$(wpctl get-volume @DEFAULT_AUDIO_SINK@)
volume=$(awk '{print $2 * 100}' <<< "$message")
min_volume="0"
max_volume="100"
if [[ $(awk '{print $3}' <<< "$message") == "[MUTED]" ]]; then
muted=1
else
muted=0
fi
# Check if an argument is provided
if [[ -z $1 ]]; then
echo "Error: Number argument is missing."
exit 1
fi
echo '{"volume":"'"$volume"'","muted":"'"$muted"'"}'
}
# Retrieve the argument value
number_to_add=$1
generate
# Validate if the argument is a number
if ! [[ $number_to_add =~ ^-?[0-9]+$ ]]; then
echo "Error: Invalid number argument."
exit 1
fi
pactl subscribe | while read -r event; do
if [[ "$event" == *"Event 'change'"* ]]; then
# Read the current brightness value from the file
current_volume=$(wpctl get-volume @DEFAULT_AUDIO_SINK@ | awk '{print $2 * 100}')
generate
# Add the desired number to the current brightness
new_volume=$((current_volume + number_to_add))
fi
done
# Enforce minimum and maximum brightness values
if (( new_volume < min_volume )); then
new_volume=$min_volume
elif (( new_volume > max_volume )); then
new_volume=$max_volume
fi
wpctl set-volume @DEFAULT_AUDIO_SINK@ "${new_volume}%"

34
scripts/workspaces.sh Executable file
View file

@ -0,0 +1,34 @@
#!/usr/bin/env bash
# Check if an argument is provided
if [[ -z $1 ]]; then
# echo "Error: Number argument is missing."
exit 1
fi
# Retrieve the argument value
new_workspace=$1
if [[ $new_workspace == special:* ]]; then
hyprctl dispatch togglespecialworkspace "${new_workspace:8}"
exit 0
fi
# Validate if the argument is a number
if ! [[ $new_workspace =~ ^-?[0-9]+$ ]]; then
# echo "Error: Invalid number argument."
exit 1
fi
while read -r i a f;do
workspace[$a]=$i
if [[ $f == true ]]; then
active=$i
fi
done < <(hyprctl monitors -j | jq -r '.[]|"\(.id) \(.activeWorkspace.id) \(.focused)"')
if [[ ${workspace[$new_workspace]} ]]; then
hyprctl dispatch swapactiveworkspaces $active ${workspace[$new_workspace]}
else
hyprctl --batch "dispatch moveworkspacetomonitor $new_workspace $active ; dispatch workspace $new_workspace"
fi