update ags
This commit is contained in:
1 parent
88822cb8e8
commit
a9c19bd2e1
134 files changed
+4732
-5813
No files matched your search
Executable
+88
@@ -0,0 +1,88 @@
|
||||
#!/bin/bash
|
||||
LOCKFILE=/tmp/smooth_backlight.lock
|
||||
BRIGHTNESS=/tmp/set_backlight
|
||||
smooth() {
|
||||
if [ -n "$1" ]; then
|
||||
rounded_value=$(echo "scale=0; $1/1" | bc)
|
||||
echo $rounded_value > $BRIGHTNESS
|
||||
else
|
||||
echo "Not enough arguments"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -e "$LOCKFILE" ] && kill -0 "$(cat $LOCKFILE)"; then
|
||||
echo "locked"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
trap "rm -f $LOCKFILE; exit" INT TERM EXIT
|
||||
echo $$ > "$LOCKFILE"
|
||||
|
||||
smooth_brightness() {
|
||||
local max_brightness=$(brightnessctl m)
|
||||
local step=$((max_brightness / 100))
|
||||
|
||||
while true; do
|
||||
local target_brightness=$(cat $BRIGHTNESS)
|
||||
local current_brightness=$(brightnessctl g)
|
||||
target_brightness=$(echo "$max_brightness * $target_brightness / 100" | bc)
|
||||
|
||||
if [ $current_brightness -eq $target_brightness ]; then
|
||||
exit 0
|
||||
fi
|
||||
while [ $current_brightness -ne $target_brightness ]; do
|
||||
if [ $current_brightness -lt $target_brightness ]; then
|
||||
current_brightness=$((current_brightness + step))
|
||||
else
|
||||
current_brightness=$((current_brightness - step))
|
||||
fi
|
||||
|
||||
brightnessctl s $current_brightness > /dev/null 2>&1
|
||||
sleep 0.001
|
||||
|
||||
local new_target_brightness=$(cat $BRIGHTNESS)
|
||||
new_target_brightness=$(echo "$max_brightness * $new_target_brightness / 100" | bc)
|
||||
if [ $new_target_brightness -ne $target_brightness ]; then
|
||||
target_brightness=$new_target_brightness
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
done
|
||||
}
|
||||
|
||||
smooth_brightness
|
||||
|
||||
rm -f "$LOCKFILE"
|
||||
trap - INT TERM EXIT
|
||||
}
|
||||
|
||||
set() {
|
||||
if [ -n "$1" ]; then
|
||||
brightnessctl s $1
|
||||
else
|
||||
echo "Not enough arguments"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
get() {
|
||||
if [ -e "$LOCKFILE" ] && kill -0 "$(cat $LOCKFILE)"; then
|
||||
local target_brightness=$(cat $BRIGHTNESS)
|
||||
echo $target_brightness
|
||||
exit 0
|
||||
fi
|
||||
brightness=$(brightnessctl g)
|
||||
max_brightness=$(brightnessctl m)
|
||||
percentage=$((100 * brightness / max_brightness))
|
||||
|
||||
echo "$percentage"
|
||||
}
|
||||
|
||||
if [[ "$1" == "--smooth" ]]; then
|
||||
smooth $2
|
||||
elif [[ "$1" == "--set" ]]; then
|
||||
set $2
|
||||
elif [[ "$1" == "--get" ]]; then
|
||||
get
|
||||
fi
|
||||
Executable
+47
@@ -0,0 +1,47 @@
|
||||
#!/bin/bash
|
||||
|
||||
monitor() {
|
||||
old_status=$(bluetoothctl show | grep "Powered: " | awk '{print $2}')
|
||||
|
||||
while true; do
|
||||
status=$(bluetoothctl show | grep "Powered: " | awk '{print $2}')
|
||||
|
||||
if [ "$status" != "$old_status" ]; then
|
||||
echo $status
|
||||
old_status=$status
|
||||
fi
|
||||
|
||||
sleep 1
|
||||
done
|
||||
}
|
||||
|
||||
get_status() {
|
||||
status=$(bluetoothctl show | grep "Powered: " | awk '{print $2}')
|
||||
echo $status
|
||||
}
|
||||
|
||||
set() {
|
||||
power=$1
|
||||
bluetoothctl power $power
|
||||
}
|
||||
|
||||
toggle() {
|
||||
status=$(bluetoothctl show | grep "Powered: " | awk '{print $2}')
|
||||
if [[ $status == "yes" ]]; then
|
||||
bluetoothctl power off > /dev/null
|
||||
get_status
|
||||
else
|
||||
bluetoothctl power on > /dev/null
|
||||
get_status
|
||||
fi
|
||||
}
|
||||
|
||||
if [[ "$1" == "--get" ]]; then
|
||||
get_status
|
||||
elif [[ "$1" == "--set" ]]; then
|
||||
{ set "$2"; }
|
||||
elif [[ "$1" == "--monitor" ]]; then
|
||||
monitor
|
||||
elif [[ "$1" == "--toggle" ]]; then
|
||||
toggle
|
||||
fi
|
||||
Executable
+51
@@ -0,0 +1,51 @@
|
||||
#!/bin/bash
|
||||
# I tried to make it smooth, but it didn't work
|
||||
|
||||
|
||||
LOCKFILE=/tmp/brightness.lock
|
||||
|
||||
get_brightness() {
|
||||
busctl --user get-property rs.wl-gammarelay / rs.wl.gammarelay Brightness | awk '{print $2}'
|
||||
}
|
||||
|
||||
set_brightness() {
|
||||
# if [ -e "$LOCKFILE" ] && kill -0 "$(cat $LOCKFILE)"; then
|
||||
# exit 0
|
||||
# fi
|
||||
# trap "rm -f $LOCKFILE; exit" INT TERM EXIT
|
||||
# echo $$ > "$LOCKFILE"
|
||||
if (( $(echo "$1 < 0.05" | bc -l) )); then
|
||||
BRIGHTNESS=0.05
|
||||
else
|
||||
BRIGHTNESS=$1
|
||||
fi
|
||||
busctl --user -- set-property rs.wl-gammarelay / rs.wl.gammarelay Brightness d $BRIGHTNESS
|
||||
# rm -f "$LOCKFILE"
|
||||
# trap - INT TERM EXIT
|
||||
}
|
||||
|
||||
set() {
|
||||
if [ -n "$1" ]; then
|
||||
set_brightness $1
|
||||
else
|
||||
echo "Not enough arguments"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
get() {
|
||||
if [ -e "$LOCKFILE" ] && kill -0 "$(cat $LOCKFILE)"; then
|
||||
local target_brightness=$(cat $BRIGHTNESS)
|
||||
echo $target_brightness
|
||||
exit 0
|
||||
fi
|
||||
percentage=$(get_brightness)
|
||||
|
||||
echo "$percentage"
|
||||
}
|
||||
|
||||
if [[ "$1" == "--set" ]]; then
|
||||
set $2
|
||||
elif [[ "$1" == "--get" ]]; then
|
||||
get
|
||||
fi
|
||||
Executable
+21
@@ -0,0 +1,21 @@
|
||||
#!/bin/bash
|
||||
|
||||
get() {
|
||||
clip_list=$(cliphist list)
|
||||
|
||||
while IFS= read -r line; do
|
||||
echo "$line" | iconv -t UTF-8
|
||||
done <<< "$clip_list"
|
||||
}
|
||||
|
||||
copy_by_id() {
|
||||
id=$1
|
||||
cliphist decode $id | wl-copy
|
||||
}
|
||||
|
||||
if [[ "$1" == "--get" ]]; then
|
||||
get
|
||||
elif [[ "$1" == "--copy-by-id" ]]; then
|
||||
{ copy_by_id "$2"; }
|
||||
fi
|
||||
|
||||
Executable
+29
@@ -0,0 +1,29 @@
|
||||
#!/bin/bash
|
||||
get_uuid() {
|
||||
local SSID="$1"
|
||||
local UUID=$(nmcli connection show | grep "$SSID" | grep wifi | awk '{print $2}')
|
||||
if [ -z "$UUID" ]; then
|
||||
echo undefined
|
||||
exit 1
|
||||
else
|
||||
echo $UUID
|
||||
fi
|
||||
}
|
||||
|
||||
edit_by_ssid() {
|
||||
local SSID="$1"
|
||||
local UUID=$(get_uuid $SSID)
|
||||
nm-connection-editor -e $UUID
|
||||
}
|
||||
|
||||
saved_networks() {
|
||||
nmcli connection show | grep "$SSID" | grep wifi | awk '{print $1}'
|
||||
}
|
||||
|
||||
if [[ "$1" == "--get" ]]; then
|
||||
get_uuid $2
|
||||
elif [[ "$1" == "--edit" ]]; then
|
||||
edit_by_ssid $2
|
||||
elif [[ "$1" == "--saved" ]]; then
|
||||
saved_networks
|
||||
fi
|
||||
Executable
+134
@@ -0,0 +1,134 @@
|
||||
#!/bin/bash
|
||||
|
||||
|
||||
get_current_temperature() {
|
||||
busctl --user get-property rs.wl-gammarelay / rs.wl.gammarelay Temperature | awk '{print $2}'
|
||||
}
|
||||
|
||||
set_temperature() {
|
||||
busctl --user set-property rs.wl-gammarelay / rs.wl.gammarelay Temperature q $1
|
||||
}
|
||||
|
||||
toggle() {
|
||||
LOCKFILE=/tmp/smooth_toggle_night_light.lock
|
||||
ENABLE=/tmp/enable
|
||||
|
||||
if [ -e "$LOCKFILE" ] && kill -0 "$(cat $LOCKFILE)"; then
|
||||
if [ -e "$ENABLE" ]; then
|
||||
if [[ $(cat $ENABLE) == "1" ]]; then
|
||||
echo 0 > $ENABLE
|
||||
echo "disabled"
|
||||
else
|
||||
echo 1 > $ENABLE
|
||||
echo "enabled"
|
||||
fi
|
||||
fi
|
||||
exit 0
|
||||
fi
|
||||
|
||||
trap "rm -f $LOCKFILE; exit" INT TERM EXIT
|
||||
echo $$ > "$LOCKFILE"
|
||||
|
||||
current_temp=$(get_current_temperature)
|
||||
|
||||
day_temp=6500
|
||||
night_temp=3500
|
||||
step=50
|
||||
delay=0.005
|
||||
|
||||
smooth_change() {
|
||||
local start_temp=$1
|
||||
local end_temp=$2
|
||||
local increment
|
||||
|
||||
if [ "$start_temp" -lt "$end_temp" ]; then
|
||||
increment=$step
|
||||
else
|
||||
increment=-$step
|
||||
fi
|
||||
|
||||
temp=$start_temp
|
||||
while [ "$temp" -ne "$end_temp" ]; do
|
||||
local mode=$(cat $ENABLE)
|
||||
|
||||
if [ "$mode" -eq 0 ]; then
|
||||
end_temp=$day_temp
|
||||
else
|
||||
end_temp=$night_temp
|
||||
fi
|
||||
|
||||
if [ "$temp" -eq "$end_temp" ]; then
|
||||
sleep 1
|
||||
continue
|
||||
fi
|
||||
|
||||
set_temperature $temp
|
||||
|
||||
if [ "$increment" -gt 0 ] && [ "$temp" -gt "$end_temp" ]; then
|
||||
temp=$end_temp
|
||||
elif [ "$increment" -lt 0 ] && [ "$temp" -lt "$end_temp" ]; then
|
||||
temp=$end_temp
|
||||
else
|
||||
temp=$((temp + increment))
|
||||
fi
|
||||
|
||||
sleep $delay
|
||||
|
||||
local new_mode=$(cat $ENABLE)
|
||||
|
||||
if [ "$new_mode" -ne "$mode" ]; then
|
||||
if [ "$new_mode" -eq 0 ]; then
|
||||
end_temp=$day_temp
|
||||
else
|
||||
end_temp=$night_temp
|
||||
fi
|
||||
|
||||
if [ "$temp" -lt "$end_temp" ]; then
|
||||
increment=$step
|
||||
else
|
||||
increment=-$step
|
||||
fi
|
||||
|
||||
temp=$(get_current_temperature)
|
||||
fi
|
||||
done
|
||||
if [ -e "$ENABLE" ]; then
|
||||
if [[ $(cat $ENABLE) == "1" ]]; then
|
||||
echo "enabled"
|
||||
else
|
||||
echo "disabled"
|
||||
fi
|
||||
fi
|
||||
set_temperature $end_temp
|
||||
}
|
||||
|
||||
if [ "$current_temp" -lt "$(( (day_temp + night_temp) / 2 ))" ]; then
|
||||
echo 0 > $ENABLE
|
||||
smooth_change $current_temp $day_temp
|
||||
else
|
||||
echo 1 > $ENABLE
|
||||
smooth_change $current_temp $night_temp
|
||||
fi
|
||||
|
||||
rm -f "$LOCKFILE"
|
||||
trap - INT TERM EXIT
|
||||
}
|
||||
|
||||
get() {
|
||||
day_temp=6500
|
||||
night_temp=5000
|
||||
|
||||
current_temp=$(get_current_temperature)
|
||||
|
||||
if [ "$current_temp" -lt "$(( (day_temp + night_temp) / 2 ))" ]; then
|
||||
echo "enabled"
|
||||
else
|
||||
echo "disabled"
|
||||
fi
|
||||
}
|
||||
|
||||
if [[ "$1" == "--toggle" ]]; then
|
||||
toggle
|
||||
elif [[ "$1" == "--get" ]]; then
|
||||
get
|
||||
fi
|
||||
Executable
+48
@@ -0,0 +1,48 @@
|
||||
#!/bin/bash
|
||||
|
||||
get_cpu_usage() {
|
||||
top -bn1 | grep "Cpu(s)" | \
|
||||
awk '{printf "%.0f\n", $2 + $4 + $6}'
|
||||
}
|
||||
|
||||
get_ram_usage() {
|
||||
free -m | awk 'NR==2{printf "%.0f\n", $3*100/$2 }'
|
||||
}
|
||||
|
||||
get_swap_usage() {
|
||||
free -m | awk 'NR==3{printf "%.0f\n", $3*100/$2 }'
|
||||
}
|
||||
|
||||
get_cpu_temp() {
|
||||
sensors | grep -i 'core ' | awk '{sum+=$3; count+=1} END {if (count > 0) print sum/count; else print "Undefined"}'
|
||||
}
|
||||
|
||||
get_cpu_name() {
|
||||
lscpu | awk -F ': +' '/Model name/ {sub(" @ .*", "", $2); print $2}'
|
||||
}
|
||||
|
||||
get_ram() {
|
||||
free -h | grep Mem | awk '{print $2}'
|
||||
}
|
||||
|
||||
get_kernel() {
|
||||
uname -r
|
||||
}
|
||||
|
||||
if [[ "$1" == "--cpu-usage" ]]; then
|
||||
get_cpu_usage
|
||||
elif [[ "$1" == "--ram-usage" ]]; then
|
||||
get_ram_usage
|
||||
elif [[ "$1" == "--swap-usage" ]]; then
|
||||
get_swap_usage
|
||||
elif [[ "$1" == "--cpu-temp" ]]; then
|
||||
get_cpu_temp
|
||||
elif [[ "$1" == "--cpu-name" ]]; then
|
||||
get_cpu_name
|
||||
elif [[ "$1" == "--cpu-cores" ]]; then
|
||||
nproc
|
||||
elif [[ "$1" == "--ram" ]]; then
|
||||
get_ram
|
||||
elif [[ "$1" == "--kernel" ]]; then
|
||||
get_kernel
|
||||
fi
|
||||
Executable
+83
@@ -0,0 +1,83 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import sys
|
||||
from dataclasses import dataclass
|
||||
from signal import SIGINT, SIGTERM, signal
|
||||
from threading import Event
|
||||
import setproctitle
|
||||
|
||||
from pywayland.client.display import Display # type: ignore
|
||||
from pywayland.protocol.idle_inhibit_unstable_v1.zwp_idle_inhibit_manager_v1 import ( # type: ignore
|
||||
ZwpIdleInhibitManagerV1,
|
||||
)
|
||||
from pywayland.protocol.wayland.wl_compositor import WlCompositor # type: ignore
|
||||
from pywayland.protocol.wayland.wl_registry import WlRegistryProxy # type: ignore
|
||||
from pywayland.protocol.wayland.wl_surface import WlSurface # type: ignore
|
||||
|
||||
|
||||
@dataclass
|
||||
class GlobalRegistry:
|
||||
surface: WlSurface | None = None
|
||||
inhibit_manager: ZwpIdleInhibitManagerV1 | None = None
|
||||
|
||||
|
||||
def handle_registry_global(
|
||||
wl_registry: WlRegistryProxy, id_num: int, iface_name: str, version: int
|
||||
) -> None:
|
||||
global_registry: GlobalRegistry = wl_registry.user_data or GlobalRegistry()
|
||||
|
||||
if iface_name == "wl_compositor":
|
||||
compositor = wl_registry.bind(id_num, WlCompositor, version)
|
||||
global_registry.surface = compositor.create_surface() # type: ignore
|
||||
elif iface_name == "zwp_idle_inhibit_manager_v1":
|
||||
global_registry.inhibit_manager = wl_registry.bind(
|
||||
id_num, ZwpIdleInhibitManagerV1, version
|
||||
)
|
||||
|
||||
|
||||
def main() -> None:
|
||||
done = Event()
|
||||
signal(SIGINT, lambda _, __: done.set())
|
||||
signal(SIGTERM, lambda _, __: done.set())
|
||||
|
||||
global_registry = GlobalRegistry()
|
||||
|
||||
display = Display()
|
||||
display.connect()
|
||||
|
||||
registry = display.get_registry() # type: ignore
|
||||
registry.user_data = global_registry
|
||||
registry.dispatcher["global"] = handle_registry_global
|
||||
|
||||
def shutdown() -> None:
|
||||
display.dispatch()
|
||||
display.roundtrip()
|
||||
display.disconnect()
|
||||
|
||||
display.dispatch()
|
||||
display.roundtrip()
|
||||
|
||||
if global_registry.surface is None or global_registry.inhibit_manager is None:
|
||||
print("Wayland seems not to support idle_inhibit_unstable_v1 protocol.")
|
||||
shutdown()
|
||||
sys.exit(1)
|
||||
|
||||
inhibitor = global_registry.inhibit_manager.create_inhibitor( # type: ignore
|
||||
global_registry.surface
|
||||
)
|
||||
|
||||
display.dispatch()
|
||||
display.roundtrip()
|
||||
|
||||
print("Inhibiting idle...")
|
||||
done.wait()
|
||||
print("Shutting down...")
|
||||
|
||||
inhibitor.destroy()
|
||||
|
||||
shutdown()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
setproctitle.setproctitle("wayland-idle-inhibitor.py")
|
||||
main()
|
||||
Reference in new issue
Block a user