Feat: brightness script, and refactor info script

This commit is contained in:
coolnsx
2024-03-08 16:08:44 +05:30
parent 80de39466a
commit e6aaf4139d
11 changed files with 123 additions and 40 deletions

52
hypr/brightness Executable file
View File

@@ -0,0 +1,52 @@
#!/bin/sh
##########################################################################################
# NOTE: you need to be member of "video" group or maybe "input" group for this to work.. #
##########################################################################################
########
# MAIN #
########
# dir where the backlight component resides..
root_dir="/sys/class/backlight"
#########################################################################
# brighness directory can be different per device, check above root_dir #
#########################################################################
#for intel
#backlight_dir="intel_backlight0"
#for acpi (generic)
#backlight_dir="acpi_backlight0"
#for amd
backlight_dir="amdgpu_bl1"
#file read
brightness_file="$root_dir/$backlight_dir/brightness"
current=$(cat "$brightness_file")
max=$(cat "$root_dir/$backlight_dir/max_brightness")
#runtime values
opr=$1 # [+|-], required
increment=${2:-5} # [ default:5, optional] "around 2% brightness"
#shellcheck disable=SC2004
[ "$opr" = "s" ] && printf "%s" "$((${current}00/${max}))" && exit 0
#validation
(! printf '%s' "$opr" | grep -qE '[+-]') && notify-send -u critical "Unknown Operator, use only + or -" && exit 1
#shellcheck disable=SC2086,SC1102
new="$(( $current $opr $increment ))"
#constraints
[ "$new" -ge "$max" ] && new=$max
[ "$new" -le 0 ] && new=0
#new brightness value
printf '%s' "$new" > "$brightness_file"
#shellcheck disable=SC2004
notify-send -i "lol" "☀️ $((${new}00/${max}))" -t 1000 -h "string:x-canonical-private-synchronous:${0##*/}"

View File

@@ -1,15 +1,32 @@
# See https://wiki.hyprland.org/Configuring/Monitors/
monitor=,highrr,auto,1.6,bitdepth,10
#monitor=,2880x1800@120,auto,1.6,bitdepth,10
monitor=,highrr,auto,1.5,bitdepth,10
#monitor=,2880x1800@120.000999,auto,1.5,bitdepth,10
$hypr_dir="$HOME/.config/hypr"
$accent=D81860
#envs
env = XDG_SESSION_TYPE,wayland
env = WLR_NO_HARDWARE_CURSORS,1
env = BROWSER,google-chrome-stable
env = EDITOR,nvim
env = GDK_BACKEND,wayland,x11
env = GDK_SCALE,2 #xwayland fractional scaling
env = GTK_THEME,Materia-dark
env = GLOBAL_ACCENT,$accent
env = IMAGE,nsxiv
env = LIBSEAT_BACKEND,logind
env = MOZ_ENABLE_WAYLAND,1
env = OPENER,xdg-open
env = QT_QPA_PLATFORMTHEME,qt5ct
env = QT_QPA_PLATFORM,wayland
env = SDL_VIDEODRIVER,wayland
env = TERMINAL,foot
env = VIDEO,mpv
env = VISUAL,nvim
env = WLR_NO_HARDWARE_CURSORS,1
env = WM,hyprland
env = XDG_CURRENT_DESKTOP,Hyprland
env = XDG_SESSION_DESKTOP,Hyprland
env = XDG_SESSION_TYPE,wayland
# See https://wiki.hyprland.org/Configuring/Keywords/ for more
# For all categories, see https://wiki.hyprland.org/Configuring/Variables/
@@ -87,6 +104,11 @@ gestures {
misc {
force_default_wallpaper = 0
vfr = 1
vrr = 2
}
xwayland {
force_zero_scaling = false
}
# See https://wiki.hyprland.org/Configuring/Keywords/ for more
@@ -164,11 +186,11 @@ binde=, XF86AudioRaiseVolume, exec, pamixer --set-limit 140 --allow-boost -i 2 &
binde=, XF86AudioMute, exec, pamixer --set-limit 140 --allow-boost -t && $hypr_dir/volume
binde=, XF86AudioPlay, exec, echo cycle pause | socat - "/tmp/yt-music/yt-music-mpvsocket"
binde=, XF86AudioPause, exec, echo cycle pause | socat - "/tmp/yt-music/yt-music-mpvsocket"
binde=$mainMod, F10, exec, $HOME/repos_scripts/yt-music search_play
binde= $mainMod, F10, exec, $HOME/repos_scripts/yt-music search_play
binde=, XF86AudioNext, exec, $HOME/repos_scripts/yt-music play_next
binde=, XF86AudioPrev, exec, $HOME/repos_scripts/yt-music play_next menu
binde=, XF86MonBrightnessDown, exec, light -U 2 && notify-send -i "lol" "☀️ $(light -G | cut -d'.' -f1)" -t 1000 -h "string:x-canonical-private-synchronous:brightness"
binde=, XF86MonBrightnessUp, exec, light -A 2 && notify-send -i "lol" "☀️ $(light -G | cut -d'.' -f1)" -t 1000 -h "string:x-canonical-private-synchronous:brightness"
binde=, XF86MonBrightnessUp, exec, $hypr_dir/brightness '+'
binde=, XF86MonBrightnessDown, exec, $hypr_dir/brightness '-'
#windows rules
windowrulev2=workspace 1,class:^(google-chrome)$
@@ -179,16 +201,19 @@ windowrulev2=workspace 4,class:^(pavucontrol)$
windowrulev2=workspace 4,class:^(org.freedesktop.Xwayland)$
windowrulev2=fullscreen,class:^(org.freedesktop.Xwayland)$
windowrulev2=workspace 4,class:^(virt-manager)$
windowrulev2 = bordercolor rgba(64f2a4FF), xwayland: 1
windowrulev2=bordercolor rgba(64f2a4FF), xwayland: 1
#workspace rules
workspace = 1, on-created-empty:google-chrome-stable
workspace = 2, on-created-empty:foot
#startup applications
exec-once=dbus-update-activation-environment --systemd --all
exec-once=ssh-agent
exec-once=/usr/lib/polkit-gnome/polkit-gnome-authentication-agent-1
exec-once=node $HOME/github/arrpc/src > /tmp/arrpc-log
exec-once=swaybg -i $HOME/.config/wall/9.png
exec-once=swaybg -i $HOME/.config/wall/19.jpg -m fill
exec-once=xrdb -merge $HOME/.config/.Xresource
exec-once=$hypr_dir/workspace 'focus'
exec-once=$hypr_dir/battery
#exec-once=sleep 2 && $hypr_dir/workspace
exec-once=google-chrome-stable

View File

@@ -1,20 +1,19 @@
#!/bin/sh
i=1
mem_total=$(sed -nE 's_.*MemTotal:[[:space:]]*(.*) kB_\1_p' /proc/meminfo)
mem_total_mb=$((mem_total / 1024))
while [ $i -le 5 ]; do
mem=$(sed -nE 's_.*Active:[[:space:]]*(.*) kB_\1_p' /proc/meminfo)
mem="$((mem / 1024))"
temp=$(cat /sys/class/thermal/thermal_zone0/temp)
temp=$((temp / 1000))
bat_stats=$(cat /sys/class/power_supply/BAT0/status)
vol_stats=$(pamixer --get-mute)
charge=$(cat /sys/class/power_supply/BAT*/capacity)
[ "$bat_stats" = "Discharging" ] && bat_icon=🔋 || bat_icon=🔌
[ "$bat_stats" = "Discharging" ] && [ "$charge" -lt 20 ] && bat_icon="🪫"
[ "$vol_stats" = "true" ] && vol_icon=🔇 || vol_icon=🔊
notify-send -i "lol" "<----------(STATS)---------->" "🧠 CPU usage : $(top -ibn1 | sed -nE 's_%Cpu\(s\):(.*)us.*_\1_p' | cut -d' ' -f2-3) %\n🌡 Cpu Temp : $temp °C\n🔳 RAM : $mem MB / $mem_total_mb MB\n$bat_icon Battery : $charge (${bat_stats})\n☀ Brightness : $(light -G | cut -d'.' -f1)%\n$vol_icon Volume : $(pamixer --get-volume-human)\n🎵 $(pgrep -af mpvsocket >/dev/null && cut -d ">" -f1 /tmp/yt-music/current | cut -d":" -f2)" -h "string:x-canonical-private-synchronous:${0##*/}" -t 1500 &
: $((i += 1))
sleep 1
top -ibn5 -d1 | while read -r line;do
new_cpu=$(printf "%s" "$line" | sed -nE 's_%Cpu\(s\):[[:space:]]*(.*) us,.*_\1 %_p')
new_mem=$(printf "%s" "$line" | sed -nE 's_MiB Mem :[[:space:]]*(.*) total,.*,[[:space:]]*(.*) used,.*_\2 MB / \1 MB_p')
cpu=${new_cpu:-$cpu}
mem=${new_mem:-$mem}
if [ -n "$new_mem" ];then
temp=$(cat /sys/class/thermal/thermal_zone0/temp)
: $((temp /= 1000))
bat_stats=$(cat /sys/class/power_supply/BAT0/status)
vol_stats=$(pamixer --get-volume-human)
charge=$(cat /sys/class/power_supply/BAT0/capacity)
[ "$bat_stats" = "Discharging" ] && { [ "$charge" -lt 20 ] && bat_icon=🪫 || bat_icon=🔋 ;} || bat_icon=🔌
[ "$vol_stats" = "muted" ] && vol_icon=🔇 || vol_icon=🔊
notify-send -i "lol" "<----------(STATS)---------->" "🧠 CPU usage : $cpu\n🌡 Cpu Temp : $temp °C\n🔳 RAM : $mem\n$bat_icon Battery : $charge (${bat_stats})\n☀ Brightness : $("$(dirname "$0")"/brightness s)%\n$vol_icon Volume : $vol_stats\n🎵 $(cut -d ">" -f1 /tmp/yt-music/current 2>/dev/null | cut -d":" -f2)" -h "string:x-canonical-private-synchronous:${0##*/}" -t 1500 &
fi
done

View File

@@ -12,4 +12,4 @@ gamename=$(basename "$game")
notify-send -h "string:x-canonical-private-synchronous:${0##*/}" -i "wine" "Launching $gamename"
RADV_PERFTEST=gpl DXVK_ASYNC=1 gamemoderun mangohud wine "$gamename"
WINEFSYNC=1 WINEESYNC=1 MANGOHUD=1 gamemoderun wine "$gamename"