Custom screensaver with a bash script

Style your desktop
Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Post Reply
User avatar
axrusar
Level 7
Level 7
Posts: 1515
Joined: Sat Jan 30, 2021 5:30 pm

Custom screensaver with a bash script

Post by axrusar »

Guys, is there a way to run a screensaver from a bash script in Mint Cinnamon 20.3?
Here is my script:

Code: Select all

#!/bin/bash

# Set the desired zoom level
zoom_level=1.8

# Command to run with arguments
command="unimatrix -s 95"

# Open GNOME Terminal in full screen mode without toolbar and set zoom level
gnome-terminal --full-screen --hide-menubar --zoom=$zoom_level -- $command
So the script runs unimatrix in a gnome-terminal full screen with some settings i like.
The screensaver panel in cinnamon does not have any options to even pick a screensaver but just setting up the lock screen.
I installed xscreensaver and i am reading their documentation but besides running custom video clips or picking a directory for a slideshow of images, i do not see an option to run a script.

Any other ideas?
Thank you
Linux Mint Una Cinnamon 20.3 Kernel: 5.15.x | Quad Core I7 4.2Ghz | 24GB Ram | 1TB NVMe | Intel Graphics
Image
User avatar
Koentje
Level 7
Level 7
Posts: 1581
Joined: Tue Jan 04, 2022 6:23 pm
Location: Netherlands

Re: Custom screensaver with a bash script

Post by Koentje »

I have done somewhat the same with cmatrix. But i needed 2 batchfiles to start it in a fullscreen gnome terminal.
First script starts the gnome terminal in fullscreen with some other options that starts the seconds script. The second script has a loop that checks mouse movement and a second loop that sets counter to zero after 2 seconds if movement was too small (like bumping to the table).

First bash script that is started by keyboard or desktop shortcut (matrix-screensaver-start.sh)

Code: Select all

#!/bin/bash

gnome-terminal --window-with-profile=cmatrix --hide-menubar --full-screen --geometry=-10x10-3440x1440 -- $HOME/bin/matrix-screensaver.sh
Second bash script that is started by the first one (matrix-screensaver.sh)

Code: Select all

#!/bin/bash

clear

# Set terminal rows/columns
stty cols 380
stty rows 80

# Sensitivity of mouse movement
sens="350"

XXX=0


# Set x to 0 after 2 seconds
x-to-zero () {
while :
do
  sleep 2
  tee /tmp/XXX.0
done
}
x-to-zero &


# Start cmatrix screensaver
cmatrix -b -u 7 &


# Loop for mousemovement
while read -r -n6 key
do

  if [[ "$key" != "" ]]; then
    if [ "$XXX" -lt "$sens" ]; then
      if [ -f /tmp/XXX.0 ]; then
        XXX=0
        rm -f /tmp/XXX.0
      else
        ((XXX=XXX+1))
      fi
    else
      # Enough movement detected, kill cmatrix and script
      pkill -f cmatrix
      pkill -f matrix-screensaver.sh
      exit
    fi
  fi

#        xinput test "name of mouse"  (see xinput for device names)
done < <(xinput test "CoolerMaster SENTINEL III")

exit 0
Image
rickNS
Level 9
Level 9
Posts: 2981
Joined: Tue Jan 25, 2011 11:59 pm

Re: Custom screensaver with a bash script

Post by rickNS »

axrusar wrote: Tue Mar 12, 2024 7:35 am Guys, is there a way to run a screensaver from a bash script in Mint Cinnamon 20.3?

Any other ideas?
Thank you
IF you just trying to get the Matrix screensaver running ?

Install the xscreensaver-extra packages, and you can have it without any scripts;
xscreensaver
xscreesaver-gl
xscreensaver-gl-extra
xscreensaver-data-extra

Disable Cinnamon's screensaver, by setting the timer to "never", then make a startup item for xcsreensaver. Re-login.

From Menu, Screensaver(Xscreensaver-demo) you can select either glmatrix, or xmatrix.
Mint 20.0, and 21.0 MATE on Thinkpads, 3 X T420, T450, T470, and X200
Post Reply

Return to “Themes, Icons & Wallpaper”