diff options
Diffstat (limited to 'unix/sys')
| -rwxr-xr-x | unix/sys/battery_alert.sh | 43 | ||||
| -rwxr-xr-x | unix/sys/gsettings.sh | 40 | ||||
| -rwxr-xr-x | unix/sys/keep_guest_awake.sh | 84 | ||||
| -rwxr-xr-x | unix/sys/low-bat-notifier | 79 | ||||
| -rwxr-xr-x | unix/sys/session_manager.sh | 72 | ||||
| -rwxr-xr-x | unix/sys/shutdown_watchdog | 11 |
6 files changed, 0 insertions, 329 deletions
diff --git a/unix/sys/battery_alert.sh b/unix/sys/battery_alert.sh deleted file mode 100755 index 47fa556..0000000 --- a/unix/sys/battery_alert.sh +++ /dev/null @@ -1,43 +0,0 @@ -#!/bin/sh - -# Send a notification if the laptop battery is either low or is fully charged. - -# Battery percentage at which to notify -WARNING_LEVEL=78 -CRITICAL_LEVEL=5 -BATTERY_DISCHARGING=$(acpi -b | grep "Battery 0" | grep -c "Discharging") -BATTERY_LEVEL=$(acpi -b | grep "Battery 0" | grep -P -o '[0-9]+(?=%)') - -# Use files to store whether we've shown a notification or not (to prevent multiple notifications) -FULL_FILE=/tmp/batteryfull -EMPTY_FILE=/tmp/batteryempty -CRITICAL_FILE=/tmp/batterycritical - -# Reset notifications if the computer is charging/discharging -if [ "$BATTERY_DISCHARGING" -eq 1 ]; then - # Battery is discharging - if [ -f "$FULL_FILE" ]; then - command rm "$FULL_FILE" - fi - if [ "$BATTERY_LEVEL" -le "$WARNING_LEVEL" ] && [ ! -f "$EMPTY_FILE" ]; then - notify-send "Low Battery" "${BATTERY_LEVEL}% of battery remaining." -u critical -i "battery-low-symbolic" -r 9991 - touch "$EMPTY_FILE" - fi - if [ "$BATTERY_LEVEL" -le "$CRITICAL_LEVEL" ] && [ ! -f "$CRITICAL_FILE" ]; then - notify-send "Battery Critical" "The computer will shut down soon." -u critical -i "battery-caution-symbolic" -r 9991 - touch "$CRITICAL_FILE" - fi -elif [ "$BATTERY_DISCHARGING" -eq 0 ]; then - # Battery is charging - if [ "$BATTERY_LEVEL" -gt 99 ] && [ ! -f "$FULL_FILE" ]; then - notify-send "Battery Charged" "Battery is fully charged." -i "battery-full-symbolic" -r 9991 - touch "$FULL_FILE" - fi - # Reset empty/critical notifications when charging begins - if [ -f "$EMPTY_FILE" ]; then - command rm "$EMPTY_FILE" - fi - if [ -f "$CRITICAL_FILE" ]; then - command rm "$CRITICAL_FILE" - fi -fi diff --git a/unix/sys/gsettings.sh b/unix/sys/gsettings.sh deleted file mode 100755 index 9054344..0000000 --- a/unix/sys/gsettings.sh +++ /dev/null @@ -1,40 +0,0 @@ -#!/bin/bash - -# Disable screen lock -gsettings set org.gnome.desktop.screensaver lock-enabled false -gsettings set org.gnome.desktop.session idle-delay 0 - -# Mutter Overlay Key -gsettings set org.gnome.mutter overlay-key '' - -# Disable update notification -#gsettings set org.gnome.software download-updates false -#gsettings set com.ubuntu.update-notifier no-show-notifications true -#sudo rm /etc/xdg/autostart/upg-notifier-autostart.desktop - -#sudo mv /etc/xdg/autostart/update-notifier.desktop /etc/xdg/autostart/update-notifier.desktop.old -#sudo mv /etc/xdg/autostart/gnome-software-service.desktop /etc/xdg/autostart/gnome-software-service.desktop.old - -# Custom Keybinding Names -gsettings set org.gnome.settings-daemon.plugins.media-keys custom-keybindings "['/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0/']" - -# Custom Keybinding 0 -gsettings set org.gnome.settings-daemon.plugins.media-keys.custom-keybinding:/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0/ binding "<Alt>T" -gsettings set org.gnome.settings-daemon.plugins.media-keys.custom-keybinding:/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0/ command "scratchpad" -gsettings set org.gnome.settings-daemon.plugins.media-keys.custom-keybinding:/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0/ name "scratchpad" - -# Disable keyboard plugin -gsettings set org.gnome.settings-daemon.plugins.keyboard active false - -# Prefer dark mode -gsettings set org.gnome.desktop.interface color-scheme 'prefer-dark' - -# Default terminal -gsettings set org.cinnamon.desktop.default-applications.terminal exec wezterm - -# Disable screensaver -gsettings set org.gnome.desktop.session idle-delay 0 -gsettings set org.gnome.desktop.screensaver lock-enabled false - -# Hack -#gsettings set org.gnome.desktop.app-folders folder-children "['Red', 'SysAdmin', 'Blue']" diff --git a/unix/sys/keep_guest_awake.sh b/unix/sys/keep_guest_awake.sh deleted file mode 100755 index 13d839b..0000000 --- a/unix/sys/keep_guest_awake.sh +++ /dev/null @@ -1,84 +0,0 @@ -#!/bin/bash - -# Host-side script to keep QEMU guest display awake without triggering anything -# and handle Windows key logic (disable it in the guest, map Caps Lock to Windows key). - -MONITOR_SOCKET_DIR="$HOME/machines/vm" -QEMU_CLASS="qemu-system-x86_64" -SEND_CMD_MONITOR="sendkey f15" -SEND_CMD_XDO="key --clearmodifiers F15" -DISABLE_WINDOWS_KEY_CMD="sendkey meta_l NoSymbol" # Using ctrl_l as a placeholder -CAPS_LOCK_CMD="sendkey meta_l" # Remapped Caps Lock to Super_L (Windows key) - -## Function to disable the Windows key and remap Caps Lock to Super_L -#disable_windows_key_and_remap_caps_lock() { -# shopt -s nullglob -# sockets=("$MONITOR_SOCKET_DIR"/*.socket) -# shopt -u nullglob -# -# for socket in "${sockets[@]}"; do -# # Get VM name from socket file -# VM_NAME=$(basename "$socket" .socket) -# VM_NAME=${VM_NAME%-serial} -# -# # Send QMP command to disable Windows key (Super_L key press/remap) -# qmp_command='{"execute": "device_key_press", "arguments": {"dev": "virtio-keyboard-pci", "key": "capslock"}}' -# echo "$qmp_command" | socat - "UNIX-CONNECT:$socket" >/dev/null -# -# # Send QMP command to remap Caps Lock to Super_L (Windows key) -# qmp_command='{"execute": "guest-execute", "arguments": {"path": "/usr/bin/xmodmap", "arg": ["-e", "keycode 66 = Super_L"]}}' -# echo "$qmp_command" | socat - "UNIX-CONNECT:$socket" >/dev/null -# -# # Optional: Disable Super_L key (Windows key) -# qmp_command='{"execute": "guest-execute", "arguments": {"path": "/usr/bin/xmodmap", "arg": ["-e", "keycode 133 = NoSymbol"]}}' -# echo "$qmp_command" | socat - "UNIX-CONNECT:$socket" >/dev/null -# done -#} - -# Function to keep the guest display awake by sending F15 key press -keep_guest_display_awake() { - shopt -s nullglob - sockets=("$MONITOR_SOCKET_DIR"/*.socket) - shopt -u nullglob - - if [ ${#sockets[@]} -eq 0 ]; then - sleep 30 - return - fi - - focused_qemu=false - - if command -v xdotool >/dev/null 2>&1; then - active_win_id=$(xdotool getwindowfocus 2>/dev/null) - if [ "$active_win_id" != "" ]; then - active_class=$(xdotool getwindowclassname "$active_win_id" 2>/dev/null) - if [[ "$active_class" == "$QEMU_CLASS" ]]; then - focused_qemu=true - fi - fi - fi - - if "$focused_qemu"; then - # QEMU is focused â send F15 via xdotool - #xdotool "$SEND_CMD_XDO" - echo "" - - else - # QEMU is not focused â send F15 via monitor - for socket in "${sockets[@]}"; do - echo "$SEND_CMD_MONITOR" | socat - "UNIX-CONNECT:$socket" - done - fi -} - -# Main loop -while true; do - # Handle Windows key remapping and Caps Lock disablement - #disable_windows_key_and_remap_caps_lock - - # Keep the guest display awake - keep_guest_display_awake - - # Sleep before next cycle - sleep 30 -done diff --git a/unix/sys/low-bat-notifier b/unix/sys/low-bat-notifier deleted file mode 100755 index a67b25d..0000000 --- a/unix/sys/low-bat-notifier +++ /dev/null @@ -1,79 +0,0 @@ -#!/bin/bash - -### VARIABLES - -POLL_INTERVAL=120 # seconds at which to check battery level -LAST_NOTIFIED=-1 # track last notified battery percentage to avoid repeated notifications - -# If BAT0 doesn't work for you, check available devices with: -# $ ls -1 /sys/class/power_supply/ -BAT_PATH=/sys/class/power_supply/BAT0 -BAT_STAT=$BAT_PATH/status - -if [[ -f $BAT_PATH/charge_full ]]; then - BAT_FULL=$BAT_PATH/charge_full - BAT_NOW=$BAT_PATH/charge_now -elif [[ -f $BAT_PATH/energy_full ]]; then - BAT_FULL=$BAT_PATH/energy_full - BAT_NOW=$BAT_PATH/energy_now -else - exit -fi - -kill_running() { - local mypid=$$ - local pids - mapfile -t pids < <(pgrep -f "${0##*/}") - - for pid in "${pids[@]}"; do - if [[ $pid -ne $mypid ]]; then - kill "$pid" - sleep 1 - fi - done -} - -get_battery_icon() { - local percent=$1 - if ((percent > 80)); then - echo "đ" # Full battery - elif ((percent > 60)); then - echo "đ" # High battery - elif ((percent > 40)); then - echo "đ" # Medium battery - elif ((percent > 20)); then - echo "đĒĢ" # Low battery - else - echo "â ī¸" # Critical battery - fi -} - -# Run only if battery is detected -if ls -1qA /sys/class/power_supply/ | grep -q BAT; then - - kill_running - - while true; do - bf=$(cat "$BAT_FULL") - bn=$(cat "$BAT_NOW") - bs=$(cat "$BAT_STAT") - - bat_percent=$((100 * $bn / $bf)) - bat_icon=$(get_battery_icon "$bat_percent") - - # Notify only at exact levels: 20%, 15%, and 10% - if [[ ($bat_percent -eq 20 || $bat_percent -eq 15 || $bat_percent -eq 10) && "$bs" = "Discharging" && $bat_percent -ne $LAST_NOTIFIED ]]; then - notify-send --urgency=critical "$bat_icon $bat_percent% : $([[ $bat_percent -eq 10 ]] && echo 'Critical Battery! Shutting down in 1 minute...' || echo 'Low Battery!')" - LAST_NOTIFIED=$bat_percent - - if [[ $bat_percent -eq 10 ]]; then - sleep 60 - shutdown now - fi - elif [[ "$bs" = "Charging" ]]; then - LAST_NOTIFIED=-1 - fi - - sleep "$POLL_INTERVAL" - done -fi diff --git a/unix/sys/session_manager.sh b/unix/sys/session_manager.sh deleted file mode 100755 index b6a6b03..0000000 --- a/unix/sys/session_manager.sh +++ /dev/null @@ -1,72 +0,0 @@ -#!/bin/sh - -cd ~ - -# Default session to be executed -unset DISPLAY XAUTHORITY DBUS_SESSION_BUS_ADDRESS - -session="" - -# Function to display and start the selected session -display() { - # Default list of sessions in priority order - default_sessions=("Hyprland" "bspwm" "sway") - - # Check conditions and set session command - if [ "$DISPLAY" = "" ] && [ "$XDG_VTNR" -eq 1 ]; then - if [ -f ~/.session ]; then - session=$(cat ~/.session) - rm ~/.session # Remove the session file after reading - fi - - if [ "$session" != "" ]; then - case "$session" in - bspwm ) - export XDG_SESSION_TYPE="x11" - session="startx /usr/bin/bspwm" - ;; - Hyprland | sway) - session="dbus-launch --sh-syntax --exit-with-session $session" - ;; - *) - echo "Session $session is not supported." - session="" - ;; - esac - else - # Iterate through default sessions to find a suitable one - for wm in "${default_sessions[@]}"; do - if command -v "$wm" >/dev/null 2>&1; then - case "$wm" in - bspwm ) - export XDG_SESSION_TYPE="x11" - session="startx /usr/bin/$wm" - break - ;; - Hyprland | sway) - session="dbus-launch --sh-syntax --exit-with-session $wm >/dev/null 2>&1 && exit" - #show_animation.sh - clear - break - ;; - esac - fi - done - fi - - # Execute the session command if session is set - if [ "$session" != "" ]; then - #echo "Starting session: $session" - eval "$session" - else - echo "No suitable window manager found or conditions not met." - fi - fi -} - -# Main function -main() { - display -} - -main "$@" diff --git a/unix/sys/shutdown_watchdog b/unix/sys/shutdown_watchdog deleted file mode 100755 index 79bc7bf..0000000 --- a/unix/sys/shutdown_watchdog +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/sh - -LOGFILE="/tmp/shutdown_watchdog.log" - -while true; do - echo "--- $(date) ---" >> "$LOGFILE" - uptime >> "$LOGFILE" - sensors >> "$LOGFILE" 2>/dev/null - acpi -V >> "$LOGFILE" 2>/dev/null - sleep 10 -done |
