# Unimatrix script for seasonal variations

**URL:** <https://community.learnlinux.tv/t/unimatrix-script-for-seasonal-variations/1616>\
**Category:** Homelab\
**Created:** [May 28, 2022, 9:34am UTC](https://community.learnlinux.tv/t/unimatrix-script-for-seasonal-variations/1616 "2022-05-28T09:34:26Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ameinild](https://community.learnlinux.tv/letter_avatar_proxy/v4/letter/a/51bf81/32.png) [@ameinild](https://community.learnlinux.tv/u/ameinild)\
**Post date:** [May 28, 2022, 9:34am UTC](https://community.learnlinux.tv/t/unimatrix-script-for-seasonal-variations/1616/1 "2022-05-28T09:34:26Z")

</div>

Hello

I created a Unimatrix (improved cmatrix) scripts that changes the screensaver according to seasonal events.

The following special modes are included:

- Winter: Blue snowy theme
- Easter: Green spring theme
- Solstice: Yellow summer theme
- Vacation: Cyan leasure theme
- Halloween: Purple spooky theme
- Christmas: Red cozy theme
- New Year: Rainbow confetti on 12/31 and 01/01 (takes some CPU though)

The default mode is green matrix display.

The script needs [Unimatrix](https://github.com/will8211/unimatrix) installed as well as `ncal` (to calculate date of easter) and `cmatrix` (for New Years display).

I’m using it as a tmux screensaver with the following command:

```
set -g lock-command "/home/am/bash/unimatrix.sh ; vlock"

```

This first displays the screensaver, then followed by a lock screen (vlock).

Here is the script and screenshots:

```auto
#!/bin/bash

# Current date
now=$( date )
# Manual override
#now=$( date -d 12/31/2022 )

# Define variables
nowweek=$( date -d "$now" +%V )
nowdate=$( date -d "$now" +%x )
  # Manual, because of bug in date conversion
  [["$nowweek" == "07"]] && (( nowweek = 7 ))
  [["$nowweek" == "08"]] && (( nowweek = 8 ))

easter=$( date -d "$(ncal -e)" +%V )

# Set season thresholds (week number)
(( wistar = 7 ))
(( wistop = 8 ))

(( eastar = easter ))
(( eastop = easter + 1 ))

(( sostar = 25 ))
(( sostop = 26 ))

(( vastar = 32 ))
(( vastop = 34 ))

(( hastar = 43 ))
(( hastop = 44 ))

(( chstar = 51 ))
(( chstop = 52 ))

# Debugging info
if [[1 == 0]]
then
  echo "$now"
  echo "$nowweek"
  echo "${nowdate%/*}"
  echo "$eastar"
  echo "$eastop"
  echo "$vastar"
  echo "$vastop"
fi

# Display rainbow confetti on 12/31 and 01/01
if [["${nowdate%/*}" == "12/31" || "${nowdate%/*}" == "01/01"]]
then
  cmatrix -bar
else
  # Define season from current date
  (( nowweek >= wistar && nowweek <= wistop )) && season="winter"
  (( nowweek >= eastar && nowweek <= eastop )) && season="easter"
  (( nowweek >= sostar && nowweek <= sostop )) && season="solstice"
  (( nowweek >= vastar && nowweek <= vastop )) && season="vacation"
  (( nowweek >= hastar && nowweek <= hastop )) && season="halloween"
  (( nowweek >= chstar && nowweek <= chstop )) && season="christmas"

  # Override season with parameter
  [[-n "$1"]] && season="$1"

  # Display according to season
  case "$season" in
    christmas)
      unimatrix -a -s 95 -c red -u '☺☻♡♥⚘❀❃❁✼☀♫♪☃❄❅❆★❣☃❄❅❆★❣' -l sun
      ;;
    winter)
      unimatrix -a -s 95 -c blue -u '☺☻♡♥⚘❀❃❁✼☀♫♪☃❄❅❆★❣☃❄❅❆★❣' -l sun
      ;;
    easter)
      unimatrix -a -s 95 -c green -u '☺☻♡♥⚘❀❃❁✼☀♫♪⚚⚛⚜⚵✿☘⚚⚛⚜⚵✿☘' -l sun
      ;;
    solstice)
      unimatrix -a -s 95 -c yellow -u '☺☻♡♥⚘❀❃❁✼☀♫♪⚚⚛⚜⚵✿☘⚚⚛⚜⚵✿☘' -l sun
      ;;
    vacation)
      unimatrix -a -s 95 -c cyan -u '☺☻♡♥⚘❀❃❁✼☀♫♪☄☉⚷⚵⛬⛯☄☉⚷⚵⛬⛯' -l sun
      ;;
    halloween)
      unimatrix -a -s 95 -c magenta -u '☺☻♡♥⚘❀❃❁✼☀♫♪♰⚱☢⚵☨⛼♰⚱☢⚵☨⛼' -l sun
      ;;
    *)
      unimatrix -a -s 96
      ;;
  esac
fi

```

**Default**

 ![Uni_Default](https://community.learnlinux.tv/uploads/default/original/1X/015c8050b01d676ed451204e3418212d25168243.jpeg)

**Winter**

 ![Uni_Winter](https://community.learnlinux.tv/uploads/default/original/1X/ed7ba182320ee37a23395b1b6785efdee7f9f3de.jpeg)

**Easter**

 ![Uni_Easter](https://community.learnlinux.tv/uploads/default/original/1X/bd339a3e0fe3f88e4fa02089ae9f8085afd36ff8.jpeg)

**Solstice**

 ![Uni_Solstice](https://community.learnlinux.tv/uploads/default/original/1X/c6ded89a50eadf0da097130d71e0ca5e88942881.jpeg)

**Vacation**

 ![Uni_Vacation](https://community.learnlinux.tv/uploads/default/original/1X/d8c08627e3ee27d9c30b95c77d2af81df22fd3ff.jpeg)

**Halloween**

 ![Uni_Halloween](https://community.learnlinux.tv/uploads/default/original/1X/9054f1e413525862d2c097a6b618dbd89057f386.jpeg)

**Christmas**

 ![Uni_Christmas](https://community.learnlinux.tv/uploads/default/original/1X/d47f1def227330d01e70f7b90bf4ee3d9ce93566.jpeg)

**New Year**

 ![Uni_New Year](https://community.learnlinux.tv/uploads/default/original/1X/e066ab17b9c33484b1ba59a612fcd31899046ca8.jpeg)

---

<div class="post-metadata">

**Author:** ![hulxmash](https://community.learnlinux.tv/letter_avatar_proxy/v4/letter/h/e9c0ed/32.png) [@hulxmash](https://community.learnlinux.tv/u/hulxmash)\
**Post date:** [May 28, 2022, 2:37pm UTC](https://community.learnlinux.tv/t/unimatrix-script-for-seasonal-variations/1616/2 "2022-05-28T14:37:28Z")

</div>

That is pretty cool!
