From 17c8a55bbb6d121d5119d2d281a3ea585d8dea00 Mon Sep 17 00:00:00 2001 From: Keyitdev <70140437+Keyitdev@users.noreply.github.com> Date: Thu, 24 Jul 2025 20:41:55 +0200 Subject: [PATCH] Update: Added listeners, and more shortcuts to i3 config. --- home/.config/btop/btop.conf | 14 +++++++--- home/.config/i3/config | 9 ++++--- usr/local/bin/asus_fan_listener | 47 +++++++++++++++++++++++++++++++++ usr/local/bin/asus_fan_toggle | 18 +++++++++++++ usr/local/bin/battery_listener | 37 ++++++++++++++++++++++++++ usr/local/bin/touchpad_toggle | 3 +-- 6 files changed, 119 insertions(+), 9 deletions(-) create mode 100755 usr/local/bin/asus_fan_listener create mode 100755 usr/local/bin/asus_fan_toggle create mode 100755 usr/local/bin/battery_listener diff --git a/home/.config/btop/btop.conf b/home/.config/btop/btop.conf index 1f66792..1c5f165 100644 --- a/home/.config/btop/btop.conf +++ b/home/.config/btop/btop.conf @@ -1,4 +1,4 @@ -#? Config file for btop v. 1.4.0 +#? Config file for btop v. 1.4.4 #* Name of a btop++/bpytop/bashtop formatted ".theme" file, "Default" and "TTY" for builtin themes. #* Themes should be placed in "../share/btop/themes" relative to binary or "$HOME/.config/btop/themes" @@ -50,14 +50,14 @@ graph_symbol_net = "default" graph_symbol_proc = "default" #* Manually set which boxes to show. Available values are "cpu mem net proc" and "gpu0" through "gpu5", separate values with whitespace. -shown_boxes = "proc" +shown_boxes = "proc cpu" #* Update time in milliseconds, recommended 2000 ms or above for better sample times for graphs. update_ms = 2000 #* Processes sorting, "pid" "program" "arguments" "threads" "user" "memory" "cpu lazy" "cpu direct", #* "cpu lazy" sorts top process over time (easier to follow), "cpu direct" updates top process directly. -proc_sorting = "threads" +proc_sorting = "cpu direct" #* Reverse sorting order, True or False. proc_reversed = False @@ -150,7 +150,7 @@ background_update = True custom_cpu_name = "" #* Optional filter for shown disks, should be full path of a mountpoint, separate multiple values with whitespace " ". -#* Begin line with "exclude=" to change to exclude filter, otherwise defaults to "most include" filter. Example: disks_filter="exclude=/boot /home/user". +#* Only disks matching the filter will be shown. Prepend exclude= to only show disks not matching the filter. Examples: disk_filter="/boot /home/user", disks_filter="exclude=/boot /home/user" disks_filter = "" #* Show graphs instead of meters for memory values. @@ -210,6 +210,9 @@ net_sync = True #* Starts with the Network Interface specified here. net_iface = "" +#* "True" shows bitrates in base 10 (Kbps, Mbps). "False" shows bitrates in binary sizes (Kibps, Mibps, etc.). "Auto" uses base_10_sizes. +base_10_bitrate = "Auto" + #* Show battery stats in top right if battery is present. show_battery = True @@ -226,6 +229,9 @@ log_level = "WARNING" #* Measure PCIe throughput on NVIDIA cards, may impact performance on certain cards. nvml_measure_pcie_speeds = True +#* Measure PCIe throughput on AMD cards, may impact performance on certain cards. +rsmi_measure_pcie_speeds = True + #* Horizontally mirror the GPU graph. gpu_mirror_graph = True diff --git a/home/.config/i3/config b/home/.config/i3/config index c516d7d..96ff98a 100644 --- a/home/.config/i3/config +++ b/home/.config/i3/config @@ -8,24 +8,27 @@ tiling_drag modifier titlebar font pango:Open sans 11 exec --no-startup-id dex --autostart --environment i3 exec --no-startup-id xss-lock --transfer-sleep-lock -- lock --nofork + exec_always --no-startup-id xrandr --dpi 96 exec_always --no-startup-id feh --no-fehbg --bg-fill $HOME/Pictures/wallpapers/background.png exec_always --no-startup-id $HOME/.config/polybar/launch.sh + exec_always --no-startup-id dunst & -exec_always --no-startup-id /usr/lib/polkit-kde-authentication-agent-1 & +exec_always --no-startup-id /usr/lib/mate-polkit/polkit-mate-authentication-agent-1 & +exec_always --no-startup-id asus_fan_listener & +exec_always --no-startup-id battery_listener & bindsym XF86AudioRaiseVolume exec --no-startup-id volume_control -s +5 -m 125 && volume_level bindsym XF86AudioLowerVolume exec --no-startup-id volume_control -s -5 -m 125 && volume_level bindsym XF86AudioMute exec --no-startup-id pactl set-sink-mute @DEFAULT_SINK@ toggle && volume_mute bindsym XF86AudioMicMute exec --no-startup-id pactl set-source-mute @DEFAULT_SOURCE@ toggle && microphone_mute +bindsym Ctrl+F5 exec --no-startup-id asus_fan_toggle bindsym XF86ScreenSaver exec --no-startup-id xset dpms force off bindsym XF86MonBrightnessDown exec --no-startup-id brightness_control -s -2 && brightness_level bindsym XF86MonBrightnessUp exec --no-startup-id brightness_control -s +2 && brightness_level -bindsym XF86SplitScreen exec --no-startup-id touchpad_toggle bindsym XF86TouchpadToggle exec --no-startup-id touchpad_toggle # bindsym XF86RFKill # bindsym XF86Calculator exec --no-startup-id nemo -bindsym Ctrl+F5 exec --no-startup-id rofi -show drun bindsym $mod+Return exec i3-sensible-terminal diff --git a/usr/local/bin/asus_fan_listener b/usr/local/bin/asus_fan_listener new file mode 100755 index 0000000..9c428f8 --- /dev/null +++ b/usr/local/bin/asus_fan_listener @@ -0,0 +1,47 @@ +#!/bin/sh + +# inotify-tools + +# specify the path to the fan_boost_mode file +fan_boost_mode_file="/sys/devices/platform/asus-nb-wmi/throttle_thermal_policy" + +# variable to store the previous fan boost mode +previous_mode="" + +# kill previous instances +for pid in $(pidof -x asus_fan_listener); do + if [ "$pid" != $$ ]; then + kill -9 "$pid" + fi +done + +# function to get the label for a given mode +get_mode_label() { + case $1 in + 0) echo "Performance" ;; + 1) echo "Turbo" ;; + 2) echo "Silent" ;; + *) echo "Unknown Mode" ;; + esac +} + +# function to check and send a notification if the mode has changed +check_and_send_notification() { + current_mode=$(cat "$fan_boost_mode_file") + current_label=$(get_mode_label "$current_mode") + + if [ "$current_mode" != "$previous_mode" ]; then + dunstify -a "Fan Mode" "Fan Mode" "$current_label" -r 100 + previous_mode="$current_mode" + fi +} + +# monitor for changes in the fan_boost_mode file +while inotifywait -e modify "$fan_boost_mode_file"; do + check_and_send_notification +done + +# or run always +# while true; do +# check_and_send_notification +# done \ No newline at end of file diff --git a/usr/local/bin/asus_fan_toggle b/usr/local/bin/asus_fan_toggle new file mode 100755 index 0000000..238627c --- /dev/null +++ b/usr/local/bin/asus_fan_toggle @@ -0,0 +1,18 @@ +#!/bin/sh + +# 0 Performance +# 1 Turbo +# 2 Silent + +fan_boost_mode_file="/sys/devices/platform/asus-nb-wmi/throttle_thermal_policy" +current_mode=$(cat "$fan_boost_mode_file") + +if [ "$current_mode" -eq 0 ]; then + echo 1 | pkexec tee /sys/devices/platform/asus-nb-wmi/throttle_thermal_policy +elif [ "$current_mode" -eq 1 ]; then + echo 2 | pkexec tee /sys/devices/platform/asus-nb-wmi/throttle_thermal_policy +elif [ "$current_mode" -eq 2 ]; then + echo 0 | pkexec tee /sys/devices/platform/asus-nb-wmi/throttle_thermal_policy +else + echo 0 | pkexec tee /sys/devices/platform/asus-nb-wmi/throttle_thermal_policy +fi \ No newline at end of file diff --git a/usr/local/bin/battery_listener b/usr/local/bin/battery_listener new file mode 100755 index 0000000..3cfca83 --- /dev/null +++ b/usr/local/bin/battery_listener @@ -0,0 +1,37 @@ +#!/bin/sh + +# upower + +# kill previous instances +for pid in $(pidof -x battery); do + if [ "$pid" != $$ ]; then + kill -9 "$pid" + fi +done + +dir_icons="/usr/local/bin/icons" + +# notify when below this percentage +warning_level=20 + +# how often to check battery status, in seconds +check_interval=60 + +while true; do + path_to_battery=$(upower -e | grep BAT) + battery_level=$(upower -i "$path_to_battery" | grep -E "percentage" | sed 's/[^0-9]//g') + discharging=$(upower -i "$path_to_battery" | grep -E "state" | grep -c "discharging") + time_to_empty=$(upower -i "$path_to_battery" | grep -E "time to empty" | sed 's/.*: *//') + + # check if battery is low and discharging + if [ "$battery_level" -lt "$warning_level" ] && [ "$discharging" -eq 1 ] + then + dunstify -a "Battery" \ + "Low battery: ${battery_level}%" \ + "Battery is low ($time_to_empty left)" \ + -r 100 \ + -i $dir_icons/battery.svg + fi + + sleep ${check_interval}s +done \ No newline at end of file diff --git a/usr/local/bin/touchpad_toggle b/usr/local/bin/touchpad_toggle index f4c84c7..37246e7 100755 --- a/usr/local/bin/touchpad_toggle +++ b/usr/local/bin/touchpad_toggle @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh touchad_id=$(xinput list | grep -i 'touchpad' | grep -oP 'id=\K\d+') @@ -9,7 +9,6 @@ fi state=$(xinput list-props "$touchad_id" | grep "Device Enabled" | grep -o "[01]$") -# Przełącz stan touchpada if [ "$state" -eq 1 ]; then xinput disable "$touchad_id" dunstify -a "Touchpad" "Touchpad" "Touchpad is disabled" -r 100