Scripts

Borg Backup Script

This is a fully automated save + shutdown + power control process in Bash.

Borg combines saves, system shutdown and power control via Home Assistant into a single chain. The original idea was that a large, power-hungry device should only be turned on when it is actually being backed up.

⚙️ What exactly does it do?

🔌 1. Turn on the remote machine

The first step is to turn on the target server with a Home Assistant API call:

  1. switch.turn_on → Sonoff / server rack power switch

🌐 2. Waiting for the machine to start

Then the script waits for the server to become available:

  1. continuous pinging the target machine
  2. continues only if it responds
  3. plus waiting for the complete system startup and loading of services

💾 3. Backup with BorgBackup

A main backup process:

  1. run borg create
  2. access the backup storage via SSH
  3. use lz4 compression for speed
  4. create a log file with a dated name

🧹 4. Preservation rules (prune). status (success / error)
  • prune status
  • running time
  • final result ( ✅ / ❌)
  • 🖥️ 6. Remote shutdown

    After the backup is complete:

    1. poweroff via SSH
    2. regular, safe shutdown

    🔌 7. Power off remote machine

    Finally:

    1. Home Assistant API call → switch.turn_off
    2. the whole system is physically turned off

    Github repo

    Alex
    2026-06-28 16:22:57.939784+02

    AlexCMS (this website)

    A lightweight, multilingual, self-hosted CMS based on Node.js, Express and PostgreSQL. Its goal is simple use, fast operation and easy Docker installation.

    AlexCMS provides a clean admin interface to manage the following:

    ✨ Functions

    🌍 Multilingual content

    📄 Article system

    📂 Download management

    🖼️ Gallery

    📝 Guestbook

    🔐 Security

    🧾 SEO

    📦 Log system

    🐳 Docker support

    🛠️ Technological stack

    TechnologyPurpose
    Node.jsBackend runtime
    Express.jsWeb framework
    PostgreSQLDatabase
    QuillText editor
    EJSTemplate engine
    DockerContainerization
    CaddyReverse proxy + HTTPS
    WinstonLogging
    MulterFile upload
    bcryptPassword hashing
    svg-captchaCAPTCHA
    sanitize-htmlXSS protection
    google-translate-apiTranslation
    http-proxy-agentProxy support

    🚀 Installation

    🐳 Option 1 – Docker

    Requirements

    Cloning

    git clone https://github.com/Pucur/AlexCMS.git
    cd AlexCMS

    Environment files

    .session

    SESSION_SECRET=super_secret_key

    .env

    DB_PASSWORD=jelszo
    ADMIN_USER=Admin
    ADMIN_PASSWORD=eros_jelszo

    Start

    docker compose up -d

    🌐 Access

    http://localhost

    or

    http://SERVER_IP

    📦 Running services

    ☁️ Option 2 - Cloud (OCI + GitHub Actions)

    Fully automated CI/CD system with Oracle Cloud infrastructure.

    Includes:

    ⚙️ GitHub Secrets

    🚀 Deploy process

    docker compose up -d --build

    🌐 Result

    http://SERVER_IP

    https://example.com

    🔐 Security

    📊 Database tables

    🐳 Docker services

    Github repo

    Alex
    2026-06-11 14:50:39.935347+02

    Wheels on the Bus RPi Projekt

    A full-featured Raspberry Pi control system for a toy bus model that plays music, manages LED effects, streams live camera footage, monitors battery and provides a modern web control interface.

    Perfect for DIY IoT projects, smart toys and interactive constructions.

    🎯 Features

    1. Two TM1637 displays and SSD1306 OLED dashboard
    2. MPV based music playback (MP3/WAV)
    3. WS2812B LED effects
    4. MJPEG + RTSP live camera stream
    5. INA226 battery monitoring
    6. USB gamepad support
    7. PWM motor and steering control
    8. Flask + SocketIO web control interface
    9. PyAudio microphone + MPG123 sound effects
    10. Clock mode and sleep mode

    The bus horn sounds every full hour.

    📸 Project pictures

    🛠️ Hardware

    Raspberry Pi (Zero 2 / 4 recommended)

    GPIO allocation:

    1. Motor ENA: GPIO 5
    2. Motor IN1: GPIO 26
    3. Motor IN2: GPIO 12
    4. Motor IN3: GPIO 16
    5. Motor IN4: GPIO 20
    6. LED: GPIO 25
    7. WS2812B LED: GPIO 13
    8. TM1637 #1 CLK: GPIO 23
    9. TM1637 #1 DIO: GPIO 24
    10. TM1637 #2 CLK: GPIO 27
    11. TM1637 #2 DIO: GPIO 22

    I2C Devices

    1. SSD1306 OLED: 0x3C
    2. INA226: 0x40

    More hardware

    1. Raspberry Pi camera module
    2. USB speaker
    3. USB microphone
    4. USB gamepad

    📦 Python dependencies

    Installation:

    pip install rpi-ws281x evdev luma.oled flask-socketio pyaudio numpy tm1637 pillow smbus2 aiohttp

    ⚙️ Configuration

    Important variables:

    MUSICDIR = "/home/$PATH/script/music"
    AUDIOBOOKDIR = "/home/$PATH/script/hangoskonyv"
    currentvolume = 35 currentspeedpercent = 100
    micvolume = 0.4
    camerawidth, cameraheight = 854, 480

    SSL files:

    1. fullchain.pem
    2. privkey.pem

    MPV socket:

    1. /tmp/mpvsocket

    🚀 Quickstart

    1. System dependencies:
    sudo apt update sudo apt install mpg123 python3-pip i2c-tools
    1. Python packages:
    pip3 install -r requirements.txt
    1. Settings:
    sudo raspi-config

    (Enable I2C, Camera, SSH)

    1. Start:
    python3 bus.py

    🌐 Web interface

    1. Dashboard: https://:443
    2. Camera: https://:443/stream.mjpg
    3. RTSP: rtsp://:8554/
    4. WebSocket: /ws

    🎮 Controller

    1. A: LED / sleep mode
    2. B: TM1637 off/on
    3. X: OLED off/on
    4. Y: bus mode / shuffle
    5. LB/RB: speed
    6. LT/RT: steering wheel
    7. right stick: progress
    8. D-pad: volume

    🌈 LED effects

    1. rainbow
    2. breathing - pulsating blue
    3. scanner - running light
    4. meteor – shooting star
    5. sparkle – sparkle
    6. police – flashing red/blue
    7. pulse – rainbow pulse

    🔋 Battery

    INA226 sensor:

    1. voltage
    2. current
    3. percentage

    API:

    GET /batterystatus

    🎥 Camera

    1. 854x480 or 1280x720
    2. RTSP + MJPEG
    3. WebSocket control

    🎵 Music and sound

    1. MPV playback
    2. MP3/WAV
    3. audiobook mode
    4. shuffle
    5. microphone input

    Sounds:

    1. bus horn
    2. engine sound
    3. index
    4. sleep sound

    🐛 Errors

    1. LED not working → GPIO group + reboot
    2. camera not working → vcgencmd get_camera
    3. MPV error → libmpv2
    4. I2C error → i2cdetect -y 1
    5. microphone → arecord -l
    6. HTTPS warning → self-signed certificate

    📱 Dashboard

    Web interface control:

    1. real-time control
    2. music
    3. LED
    4. drive

    🔒 Security

    1. Has HTTPS
    2. Has WebSocket
    3. only for local network

    no login system

    📈 Performance

    1. CPU: <20% idle
    2. Camera + effects: ~50%
    3. RAM: ~150MB

    Download

    Alex
    2026-05-08 09:50:16.908243+02

    CMDGochi bash tamagochi

    CMDGochi is a lightweight, interactive command-line virtual pet client written in Bash.

    Manage your digital pets easily from the terminal — create, feed, play with them and monitor their status in real time.

    🐾 Overview

    CMDGochi brings the nostalgic Tamagotchi experience to command line.

    It is designed to be simple and fun to use and allows you to manage multiple virtual pets.

    You can track:

    1. hunger 🍗
    2. happiness 😊
    3. energy ⚡
    4. health ❤️

    … all this with intuitive CLI commands.

    Let's talk whether you are a developer, system administrator or terminal fan, CMDGochi gives you a little playful recreation without leaving the console.

    👤 Profile and access

    1. 🔑 API key: after registration you will receive a unique API key to access your pets
    2. 🌐 Language support: multilingual interface (Hungarian, English, Deutsch, Français, Español, Italiano, Nederlands, Čeština, Polski)

    🐕 Pets

    🐾 Create a new pet

    1. Give them a cute name (4-16 characters)
    2. Choose a type

    Available animals:

    1. 🐱 cat
    2. 🐶 dog
    3. 🦜 parrot
    4. 🐹 hamster
    5. 🐰 rabbit
    6. 🐭 mouse
    7. 🦝 raccoon
    8. 🦡 badger

    📋 List pets

    1. View real-time statistics anytime
    2. Display ASCII art in the terminal 🖥️

    🗑️ Delete pet

    1. When the time has come, you can say goodbye to a pet

    📊 Pet status

    ⏳ Real-time statistics

    1. hunger 🍗
    2. happiness 😊
    3. energy ⚡
    4. health ❤️

    These are constantly changing over time.

    🩹 Health

    1. If hunger increases to the maximum:
    2. happiness and energy decrease
    3. If the pet is sick 🤒 or needs a bath 🛁:
    4. health decreases

    🎂 Growth

    1. Pets level up and age every 4 days
    2. When health is 0:
    3. growth stops 🧊

    🎮 Play and care

    1. 🍎 Feeding: reduces hunger and increases happiness
    2. 🧸 Play: improves mood but reduces energy
    3. 🛌 Sleep: replenishes energy but increases hunger
    4. 🛁 Bathing: keeps clean and improves health
    5. 💊 Medicine: treats disease and improves well-being

    Pets can get sick randomly 🤧, but they can be cured with medicine.

    🏆 Pet Hall of Fame

    1. 🌟 Top 10 oldest pet
    2. Stats:
    3. age
    4. level
    5. health
    6. happiness
    7. type

    🖥️ Server

    This API is built using Flask and SQLite to provide an easy and fun way to create virtual pets.

    1. API server: cmdgochi.mooo.com:5555
    2. Privacy: does not collect, store or handle sensitive data

    📥 Installation

    📋 Prerequisites

    1. Bash (Linux/macOS by default, Git Bash or Windows WSL)
    2. curl
    3. Unicode supported terminal

    📦 Dependencies

    Ubuntu / Debian


    sudo apt-get install jq curl git

    Arch Linux / SteamOS


    sudo pacman -S jq curl git

    RedHat / CentOS


    sudo yum install jq curl git

    Fedora


    sudo dnf install jq curl git

    macOS (Homebrew)


    brew install jq curl git

    💾 Download Repository


    git clone https://github.com/Pucur/CMDGochi.gitcd CMDGochibash cmdgochi.sh


    Github repo


    Alex
    2026-05-07 11:01:48.034132+02

    Computherm B / ProSmart System integration with HomeAssistant

    🌡️ Computherm B / ProSmart System Wi-Fi thermostat Home Assistant integration

    Connect your Computherm B / ProSmart System Wi-Fi thermostat with the Home Assistant system and take full control of your heating!

    Monitor the temperature, manage the boost mode and view the heating schedules — all on one neat dashboard.

    🔹 Functions

    🌡️ Live temperature monitoring

    Display real-time temperature values from the thermostat.

    📅 Manual and scheduled target temperature

    1. Following manual settings
    2. Monitoring scheduled temperature programs
    3. Possibility of manual temperature modification

    ⚡ Boost control

    1. Boost mode status display (ON / OFF)
    2. Remaining boost time in minutes
    3. Modification of boost temperature

    📊 Hysteresis values

    1. Monitoring upper and lower hysteresis values
    2. More accurate temperature control

    🔌 Relay and operating status

    1. Relay status (ON / OFF)
    2. Thermostat operating mode:
    3. HEATING (HEATING)
    4. COOLING (COOLING)
    5. OFF

    🔄 Fully synchronized sensors

    All data it is updated every minute with the help of the integrated data manager (coordinator) for smooth operation.

    ⚡ Installation using HACS

    Option A

    1. Search for "Computherm B / ProSmart System" integration in HACS and download it.

    Option B

    1. Open HACS with In your Home Assistant system
    2. Click on Integrations
    3. Click on the three dots in the upper right corner
    4. Choose: Custom repositories
    5. Add this URL:
    https://github.com/Pucur/prosmartsystem-computhermb-ha
    1. the Home Assistant

    📦 Configuration

    After reboot:

    1. Go to:
    2. Settings → Devices & Services → Add Integration
    3. Select:
    4. Computherm B / ProSmart System
    5. Add enter:
    6. your e-mail address
    7. password

    This is how you connect your thermostat.

    📡 Available sensors

    Sensor DescriptionTemperatureCurrent room temperatureManual Set PointManually set temperatureSchedule Set PointScheduled temperatureBoost Set PointBoost mode temperatureBoost ActiveBoost mode status (ON / OFF)Boost Remaining boost time (min)Hysteresis HighUpper hysteresis valueHysteresis LowLower hysteresis valueRelay StateRelay state (ON / OFF)FunctionThermostat operation mode (HEATING / COOLING / OFF)

    🌐 Support and bugs

    1. Documentation and updates: GitHub repository
    2. Bug report: GitHub Issues
    3. href="https://github.com/Pucur/ProSmartSystem-ComputhermB-HomeAssistant" rel="noopener noreferrer" target="_blank">Github repo


      Alex
      2026-05-07 10:54:46.929557+02

    Bing wallpapers for KDE Plasma GUI

    Information

    This is a script that downloads the latest "image of the day" from Bing.com and saves it to a selected folder.

    The script has been tested:

    1. Arch Linux 6.15.7-arch1-1
    2. KDE Plasma

    🚀 Usage

    Simply run the bing-wallpaper.sh script from the terminal.

    The script downloads today's Bing wallpaper.


    ./bing-wallpaper.sh

    ❓ Available options

    To display detailed help:


    ./bing-wallpaper.sh --help

    Usage

    Usage: bing-wallpaper.sh [options] bing-wallpaper.sh -h | --help bing-wallpaper.sh --version

    ⚙️ Options

    1. -f --force
    2. Force download. Overwrites the file if it already exists.
    3. -s --ssl
    4. Communicates with bing.com via SSL connection.
    5. -b --boost
    6. Boost mode. Try to get the last image.
    7. -q --quiet
    8. Do not show log messages.
    9. n --filename
    10. The name of the downloaded image. Defaults to the original Bing file name.
    11. -p --picturedir
    12. Full path to the download folder.
    13. Creates it automatically if it does not exist.
    14. Default:
    $HOME/Pictures/bing-wallpapers/
    1. -r --resolution
    2. The resolution of the downloaded image.
    3. Supported resolutions: UHD UHD 1920x1200 1920x1080 800x480 400x240 -w --set-wallpaper Sets the downloaded image as wallpaper on
    4. (currently only macOS supported)
    5. -h --help
    6. Show help
    7. --version
    8. Print version

    🧩 KDE setting

    To install KDE wallpaper slideshow:


    git clone https://github.com/Pucur/bing-wallpaper-kde.git

    Then set the wallpaper to use the new slideshow.

    🔄 Auto Run Setup

    To make the script run regularly:

    Startup programs

    1. Open the KDE HUD
    2. Search and: "Startup applications"
    3. Add the following script:
    4. bing-random-pic.sh or
    5. bing-wallpaper.sh

    If you want, I will also be happy to help you how to:

    1. automate with cron
    2. as a systemd service run
    3. or make a completely native wallpaper slideshow in KDE 👍


    The code:


    #!/usr/bin/env bash
    # shellcheck disable=SC1117

    SCRIPT=$(basename "$0")
    readonly SCRIPT
    SET_WALLPAPER=true
    VERSION='0.5.0'
    readonly VERSION
    RESOLUTIONS=(UHD 1920x1200 1920x1080 800x480 400x240)
    readonly RESOLUTIONS
    DATE=$(date +%Y%m%d)
    echo "Waiting for internet connection..."
    until ping -c1 8.8.8.8 &>/dev/null; do
    sleep 1
    done
    echo "Internet is up, continuing..."
    usage() {
    cat <<EOF
    Usage:
    $SCRIPT [options]
    $SCRIPT -h | --help
    $SCRIPT --version

    Options:
    -f --force Force download of picture. This will overwrite
    the picture if the filename already exists.
    -s --ssl Communicate with bing.com over SSL.
    -b --boost <n> Use boost mode. Try to fetch latest <n> pictures.
    -q --quiet Do not display log messages.
    -n --filename <file name> The name of the downloaded picture. Defaults to
    the upstream name.
    -p --picturedir <picture dir> The full path to the picture download dir.
    Will be created if it does not exist.
    [default: $HOME/Pictures/bing-wallpapers/]
    -r --resolution <resolution> The resolution of the image to retrieve.
    Supported resolutions:
    ${RESOLUTIONS[*]}
    -w --set-wallpaper Set downloaded picture as wallpaper (Only mac support for now).
    -h --help Show this screen.
    --version Show version.
    EOF
    }

    print_message() {
    if [ -z "$QUIET" ]; then
    printf "%s\n" "${1}"
    fi
    }

    # Defaults
    PICTURE_DIR="$HOME/Pictures/BingWallpaper"
    RESOLUTION="UHD"

    # Option parsing
    BOOST=1
    while [[ $# -gt 0 ]]; do
    key="$1"

    case $key in
    -r|--resolution)
    RESOLUTION="$2"
    shift
    ;;
    -p|--picturedir)
    PICTURE_DIR="$2"
    shift
    ;;
    -n|--filename)
    FILENAME="$2"
    shift
    ;;
    -f|--force)
    FORCE=true
    ;;
    -s|--ssl)
    SSL=true
    ;;
    -b|--boost)
    BOOST=$(($2))
    shift
    ;;
    -q|--quiet)
    QUIET=true
    ;;
    -h|--help)
    usage
    exit 0
    ;;
    -w|--set-wallpaper)
    SET_WALLPAPER=true
    ;;
    --version)
    printf "%s\n" $VERSION
    exit 0
    ;;
    *)
    (>&2 printf "Unknown parameter: %s\n" "$1")
    usage
    exit 1
    ;;
    esac
    shift
    done

    # Set options
    [ -n "$QUIET" ] && CURL_QUIET='-s'
    [ -n "$SSL" ] && PROTO='https' || PROTO='http'

    # Create picture directory if it doesn't already exist
    mkdir -p "${PICTURE_DIR}"

    read -ra urls < <(curl -sL "$PROTO://global.bing.com/HPImageArchive.aspx?format=js&idx=0&n=1&mkt=en-US" | \
    # Extract the image urls from the JSON response
    grep -Po '(?<=url":").*?(?=")' | \
    # Set the image resolution
    sed -e "s/[[:digit:]]\{1,\}x[[:digit:]]\{1,\}/$RESOLUTION/" | \
    # FQDN the image urls
    sed -e "s/\(.*\)/${PROTO}\:\/\/www.bing.com\1/" | \
    tr "\n" " ")

    pic="${urls[0]}"

    if [ -z "$FILENAME" ]; then
    filename=$(echo "$pic" | sed -e 's/.*[?&;]id=\([^&]*\).*/\1/' | grep -oe '[^\.]*\.[^\.]*$')
    else
    filename="$FILENAME"
    fi

    filename="${DATE}-${filename}"

    if [ -n "$FORCE" ] || [ ! -f "$PICTURE_DIR/$filename" ]; then
    print_message "Downloading: $filename..."
    curl $CURL_QUIET -Lo "$PICTURE_DIR/$filename" "$pic"
    else
    print_message "Skipping: $filename..."
    fi

    if [ -n "$SET_WALLPAPER" ]; then
    plasma-apply-wallpaperimage "$PICTURE_DIR/$filename"
    fi


    Alex
    2026-05-07 10:48:56.380196+02

    Wayland screensaver

    This handy little Bash script listens for screen saver inhibit events under Wayland and automatically stops or restarts swayidle accordingly.

    When something "blocks" the screen saver (such as a video player or presentation), the script stops swayidle so the screen doesn't lock or go to sleep. When the ban is removed, it restarts swayidle with the preset timings.

    Tested on:

    1. Arch Linux 6.17.9-arch1-1
    2. KDE Plasma 6.5.4
    3. kwin

    Notes on swayidle about how it works

    About half a year ago, I didn't know much about how swayidle works, but now I feel like I've fully understood its behavior.

    Sometimes the screensaver starts up a bit strangely, or doesn't activate exactly when you expect it to — but that's not the fault of the script, it's simply the way swayidle works. its peculiarity.

    For example:

    1. If Chrome is open and some media player is running in the background (on another tab), swayidle does not start counting the inactivity time, because it perceives it as an active process.
    2. It only starts timing when you minimize the window to the taskbar.

    A GameMode inhibit works differently:

    1. Although GameMode also uses the inhibit function, it does not affect the operation of swayidle.
    2. swayidle continues to count the inactivity time even if a game is running in full screen — which I think is a particularly good solution.

    Hence the previous "kill swayidle in all cases" approach was not really appropriate.

    This script went through several hours (actually several days... but don't tell my wife that 😄) of testing. Hopefully, this version will eliminate the problems of the previous script.

    If you still find a bug, feel free to report it in the Issues section!

    👷🏼 Operation

    The script:

    1. Monitors the Inhibit and UnInhibit DBus signals via the org.freedesktop.ScreenSaver interface. 🏞️
    2. 🎮 💻

    On UnInhibit event

    1. Restarts swayidle in proper mode 🔓

    Additional features

    1. Continuously monitors custom apps and GameMode activity 📊
    2. If custom app or GameMode runs:
    3. only screensaver mode is active 📦
    4. If none is running and no other inhibits:
    5. full mode is activated (screensaver + sleep mode) 🏞️
    6. Log:
    7. state changes
    8. inhibit/uninhibit events to the terminal 📋
    9. required:

      1. bash
      2. dbus-monitor
      3. (part of the (code>dbus package)
      4. swayidle
      5. (Wayland idle manager)
      6. xscreensaver-command
      7. (to activate the screensaver, optional)

      🧩 Install dependencies

      Arch / Manjaro (pacman)


      sudo pacman -S xscreensaver xscreensaver-extras xscreensaver-gl xscreensaver-data xscreensaver-data-extra swayidle

      Fedora (dnf)


      sudo dnf install xscreensaver xscreensaver-extras xscreensaver-gl xscreensaver-gl-extra xscreensaver-data-extra swayidle

      CentOS / RHEL (yum)


      sudo yum install xscreensaver xscreensaver-extras xscreensaver-gl xscreensaver-gl-extra xscreensaver-data-extra swayidle

      Debian / Ubuntu (apt)


      sudo apt install xscreensaver xscreensaver-data xscreensaver-gl xscreensaver-gl-extra xscreensaver-data-extra swayidle


      The code:


      #!/usr/bin/env bash

      # _ _ _ _
      # ( ) _ ( ) (_ ) ( )
      # | | ( ) | | _ _ _ _ | | _ _ ___ _| | ___ ___ _ __ __ __ ___ ___ _ _ _ _ __ _ __
      # | | | | | | /'_` )( ) ( ) | | /'_` )/' _ `\ /'_` | /',__) /'___)( '__)/'__`\ /'__`\/' _ `\/',__) /'_` )( ) ( ) /'__`\( '__)
      # | (_/ \_) |( (_| || (_) | | | ( (_| || ( ) |( (_| | \__, \( (___ | | ( ___/( ___/| ( ) |\__, \( (_| || \_/ |( ___/| |
      # `\___x___/'`\__,_)`\__, |(___)`\__,_)(_) (_)`\__,_) (____/`\____)(_) `\____)`\____)(_) (_)(____/`\__,_)`\___/'`\____)(_)
      # ( )_| |
      # `\___/'
      # ==============================
      # CONFIG
      # ==============================

      app=tixati # Put your custom app name here or leave it empty
      suspendtime=900 # Start suspend in seconds
      screensavertime=120 # Start screensaver in seconds
      apptime=60 # Suggest to set it to half than the screensaver time
      displaynumber=1 # Your display number (to get what display you using, type echo $DISPLAY in terminal)

      # ==============================
      # STATE FLAGS
      # ==============================

      current_state="NONE"
      video_inhibit=false
      last_uninhibit_time=0

      pending_uninhibit=false
      pending_uninhibit_time=0
      uninhibit_confirm=10

      initialized=0 # Run app search only once, set to 1 if you don't have any custom app

      echo "༄˖°.🍃.ೃ࿔*:・ Swayidle Inhibit Watcher v1.7 ~~ Created by Pucur - 2025.12.26 ~~ https://github.com/Pucur/wayland-screensaver ༄˖°.🍃.ೃ࿔*:・"

      stamp() {
      echo "[$(date '+%H:%M:%S')] $*"
      }

      # ==============================
      # XScreenSaver
      # ==============================

      start_screensaver() {
      while true; do
      if pgrep -x xscreensaver >/dev/null 2>&1; then
      stamp "🖼️ XScreenSaver is already running."
      break
      fi

      export DISPLAY=:$displaynumber
      export XAUTHORITY
      XAUTHORITY=$(find /run/user/$(id -u)/ -maxdepth 1 -name 'xauth_*' 2>/dev/null | head -n 1)

      xscreensaver -no-splash >/dev/null 2>&1 &
      sleep 1
      done

      }

      pkill -f swayidle 2>/dev/null

      # ==============================
      # HELPERS
      # ==============================

      STATE_DIR="/tmp/swayidle_inhibit_watcher_state"
      mkdir -p "$STATE_DIR"
      FLAG_APP_ACTIVE="$STATE_DIR/app_active"

      flag_set() { printf '%s' "$2" > "$1" 2>/dev/null; }
      flag_get() { [ -f "$1" ] && cat "$1" 2>/dev/null || printf '%s' "$2"; }

      flag_set "$FLAG_APP_ACTIVE" "0"

      kill_swayidle() {
      pkill -f xscreensaver
      pkill -f swayidle 2>/dev/null
      }

      is_game_or_app_active() {
      [ "$(flag_get "$FLAG_APP_ACTIVE" "0")" = "1" ] && return 0
      if command -v gamemoded >/dev/null 2>&1; then
      gamemoded -s 2>/dev/null | grep -vq inactive && return 0
      fi
      return 1
      }

      force_app_refresh() {
      if pgrep -x "$app" >/dev/null 2>&1; then
      flag_set "$FLAG_APP_ACTIVE" "1"
      else
      flag_set "$FLAG_APP_ACTIVE" "0"
      fi
      }

      # ==============================
      # MODES
      # ==============================

      start_screensaver_mode() {
      kill_swayidle
      start_screensaver
      stamp "🎮 Game / App running, starting screensaver without suspend"
      swayidle -w timeout "$screensavertime" 'xscreensaver-command -activate' >/dev/null 2>&1 &
      current_state="SCREENSAVER"
      }

      start_full_idle_mode() {
      kill_swayidle
      start_screensaver
      stamp "🏞️ No inhibit, normal idle with suspend"
      swayidle -w \
      timeout "$screensavertime" 'xscreensaver-command -activate' \
      timeout "$suspendtime" 'systemctl suspend' >/dev/null 2>&1 & # >/dev/null 2>&1 &
      current_state="FULL_IDLE"
      }

      # ==============================
      # APP CHECK THREAD
      # ==============================

      if [[ $initialized -eq 0 ]]; then
      initialized=1
      (
      last="0"
      while true; do
      now="0"
      pgrep -x "$app" >/dev/null 2>&1 && now="1"

      flag_set "$FLAG_APP_ACTIVE" "$now"

      if [ "$now" = "1" ] && [ "$last" != "1" ]; then
      stamp "💻 App detected → inhibit suspend"
      elif [ "$now" = "0" ] && [ "$last" != "0" ]; then
      stamp "🏞️ App stopped → normal idle allowed"
      fi

      last="$now"
      sleep "$apptime"
      done
      ) &
      fi

      # ==============================
      # MAIN LOOP
      # ==============================

      start_full_idle_mode

      dbus-monitor --session "interface='org.freedesktop.ScreenSaver'" |
      while true; do

      # --- POLLING ---
      if ! read -r -t 1 line; then

      if [ "$pending_uninhibit" = true ]; then
      if [ $(( $(date +%s) - pending_uninhibit_time )) -ge $uninhibit_confirm ]; then
      pending_uninhibit=false
      video_inhibit=false
      fi
      fi

      if [ "$video_inhibit" = true ]; then
      if [ "$current_state" != "VIDEO" ]; then
      kill_swayidle
      current_state="VIDEO"
      fi
      continue
      fi

      if is_game_or_app_active; then
      if [ "$current_state" != "SCREENSAVER" ]; then
      start_screensaver_mode
      fi
      else
      if [ "$current_state" != "FULL_IDLE" ]; then
      start_full_idle_mode
      fi
      fi

      continue
      fi

      # --- DBUS EVENTS ---
      if [[ "$line" =~ member=Inhibit ]]; then
      read -r nextline
      if ! [[ "$nextline" =~ GameMode ]]; then
      pending_uninhibit=false
      video_inhibit=true
      stamp "📺 VIDEO detected"
      kill_swayidle
      current_state="VIDEO"
      fi
      elif [[ "$line" =~ member=UnInhibit ]]; then
      read -r nextline
      if ! [[ "$nextline" =~ GameMode ]]; then
      pending_uninhibit=true
      pending_uninhibit_time=$(date +%s)
      last_uninhibit_time=$(date +%s)
      stamp "⏹️ VIDEO or APP stopped"
      force_app_refresh
      fi
      fi
      done


      Alex
      2026-05-07 10:42:55.969553+02

    Disable screensaver redshift at full screen

    Features

    1. Automatically turn on and off the screensaver depending on whether VLC is running or not
    2. Automatically turn on and off Redshift depending on whether VLC is running or not
    3. Optional:
    4. If you are mirroring your screen to a TV and want to turn off your monitor while watching a movie, you can set this up
    5. On all UNIX-like systems may work

    Required packages

    Python packages


    pip install psutil


    pip install pathlib


    pip install time


    pip install os


    pip install schedule

    System packages


    apt-get install screen


    apt-get install redshift-gtk

    (For Redshift support)


    apt-get install xscreensaver xscreensaver-data-extra xscreensaver-gl-extra

    (For screensaver support)

    Autostart

    Run:


    crontab -e

    as a user, or add it to the autostart applications.

    Then add this line:


    @reboot python /path/to/xscrred-on-vlc-off.py >/dev/null 2>&1


    import schedule
    import time, os
    import psutil
    import pathlib
    def check_process():
    PROCNAME = "vlc"
    for proc in psutil.process_iter():
    if proc.name() == 'vlc':
    return True
    else:
    return False
    def check_run():
    if check_process():
    if not pathlib.Path(".vlcwasopened").exists (): #Needs to change path here!
    #Optional, it turns off your monitor screen os.system("xrandr --output DP-3 --off") #Needs to change monitor turn-on or off outputs! Optional Feature
    os.system("screen -S xscrn -X quit")
    os.system("pkill xscreensaver")
    os.system("pkill redshift-gtk")
    os.system("touch .vlcwasopened")
    else:
    if pathlib.Path(".vlcwasopened").exists (): #Needs to change path here!
    #Optional, it turns back the monitor screen os.system("xrandr --output DP-3 --mode 1920x1080 --rate 75 --same-as LVDS-1 --mode 1920x1080 --output HDMI-2 --mode 1920x1080 --same-as DP-3") #Needs to change monitor turn-on or off outputs! Optional feature
    os.system("rm .vlcwasopened")
    os.system("screen -S xscrn -X quit")
    os.system("screen -S xscrn -d -m sh /usr/bin/python3 /usr/bin/redshift-gtk") #Needs to change path here!
    os.system("screen -S xscrn -d -m xscreensaver -nosplash") #Needs to change path here!
    schedule.every(.10).minutes.do(check_run)
    while True:
    schedule.run_pending()
    time.sleep(1)

    Alex
    2026-05-07 10:25:38.37454+02

    Unique x11 screensaver manager

    ScreenSaverOnPopOS-Ubuntu-Debian

    This is a simple script that automatically turns on the screensaver when no full-screen application is running.

    Features

    1. By default, if you do not use the computer for 2 minutes, the screensaver will appear
    2. If you remain inactive for 15 minutes, the computer will lock itself
    3. If there is no activity for 30 minutes, the computer will go into sleep mode

    Required packages

    This project requires the following packages:

    1. xfce4-screensaver
    2. (I use this because it has a nicer login screen than xscreensaver)
    3. xdg-utils
    4. xprintidle



    # check the correct display
    export DISPLAY=:1.0
    # enumerate all the attached screens
    displays="1"
    checkFullscreen()
    {
    # loop through every display looking for a fullscreen window
    for display in $displays
    do
    #get id of active window and clean output
    activ_win_id=`DISPLAY=:${display} xprop -root _NET_ACTIVE_WINDOW`
    activ_win_id=${activ_win_id:40:9}
    # Check if Active Window (the foremost window) is in fullscreen state
    isActivWinFullscreen=`DISPLAY=:${display} xprop -id $activ_win_id | grep _NET_WM_STATE_FULLSCREEN`
    if [[ "$isActivWinFullscreen" != *NET_WM_STATE_FULLSCREEN* ]];then
    checkIdle
    fi
    done
    } class="ql-code-block">

    checkIdle()
    {
    # run on your user, not as root, if not working, use sudo -u $YOURUSERNAME
    idle=$(xprintidle)
    if [ $idle -gt "120000" -a $idle -lt "900000" ]
    then
    xfce4-screensaver-command -d && xfce4-screensaver-command -a
    fi

    if [[ $idle -gt "900000" ]]
    then
    xdg-screensaver lock
    sleep 1
    xfce4-screensaver-command -d
    sleep 1
    gnome-screensaver-command -l
    fi
    echo $idle
    }
    while sleep $((60)); do
    echo $idle
    checkFullscreen
    done

    Alex
    2026-05-07 10:11:40.559162+02