Linux / Unix Desktop Fun: Christmas Tree For Your Terminal

Let us create Linux or Unix console Christmas tree and snow on your Linux desktop just for fun and profit. One can display animated Christmas tree in terminal using either Perl or Bash. First, you need to install a Perl module called Acme::POE::Tree. It is an animated Christmas tree module. I’ve tested this on Linux, OS X and Unix-like system.

ADVERTISEMENTS

How to display animated Christmas tree In Terminal

I tested the following instructions on a Debian/Ubuntu Linux 17.10/18.04 LTS (including 19.10) and CentOS Linux 7.x and macOS Unix desktop system.

Install Perl curses lib for Christmas tree

Type the following apt-get command/apt command to install lib on a Debian/Ubuntu Linux:
$ sudo apt install libcurses-perl libcurses-ui-perl libcurses-widgets-perl
Sample outputs:

[sudo] password for vivek: 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  libterm-readkey-perl
The following NEW packages will be installed:
  libcurses-perl libcurses-ui-perl libcurses-widgets-perl libterm-readkey-perl
0 upgraded, 4 newly installed, 0 to remove and 0 not upgraded.
Need to get 416 kB of archives.
After this operation, 1,338 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://archive.ubuntu.com/ubuntu eoan/universe amd64 libcurses-perl amd64 1.36-1build3 [85.0 kB]
Get:2 http://archive.ubuntu.com/ubuntu eoan/main amd64 libterm-readkey-perl amd64 2.38-1 [24.4 kB]
Get:3 http://archive.ubuntu.com/ubuntu eoan/universe amd64 libcurses-ui-perl all 0.9609-1 [229 kB]
Get:4 http://archive.ubuntu.com/ubuntu eoan/universe amd64 libcurses-widgets-perl all 1.997-7 [77.0 kB]
Fetched 416 kB in 2s (253 kB/s)                  
Selecting previously unselected package libcurses-perl.
(Reading database ... 221344 files and directories currently installed.)
Preparing to unpack .../libcurses-perl_1.36-1build3_amd64.deb ...
Unpacking libcurses-perl (1.36-1build3) ...
Selecting previously unselected package libterm-readkey-perl.
Preparing to unpack .../libterm-readkey-perl_2.38-1_amd64.deb ...
Unpacking libterm-readkey-perl (2.38-1) ...
Selecting previously unselected package libcurses-ui-perl.
Preparing to unpack .../libcurses-ui-perl_0.9609-1_all.deb ...
Unpacking libcurses-ui-perl (0.9609-1) ...
Selecting previously unselected package libcurses-widgets-perl.
Preparing to unpack .../libcurses-widgets-perl_1.997-7_all.deb ...
Unpacking libcurses-widgets-perl (1.997-7) ...
Setting up libcurses-perl (1.36-1build3) ...
Setting up libterm-readkey-perl (2.38-1) ...
Setting up libcurses-widgets-perl (1.997-7) ...
Setting up libcurses-ui-perl (0.9609-1) ...
Processing triggers for man-db (2.8.7-3) ...

If you are using a CentOS/RHEL Linux (first turn on EPEL repo on a RHEL/CentOS 7 or turn on EPEL repo on a RHEL/CentOS 6 as described here), using yum command:
$ sudo yum install perl-Curses perl-Curses-UI perl-CPAN perl-POE
If you are using a Fedora Linux, type the following dnf command:
$ sudo dnf install perl-Curses perl-Curses-UI perl-CPAN perl-POE

Install compilers and build tools on Linux

See the following docs:

Install Acme::POE::Tree

The easiest way to install any perl module is to use the cpan (Comprehensive Perl Archive Network). Open the terminal application and type the following command to install Acme::POE::Tree:

## run as root ##
perl -MCPAN -e 'install Acme::POE::Tree'

Sample outputs:

Installing /home/vivek/perl5/man/man3/POE::NFA.3pm
Installing /home/vivek/perl5/man/man3/POE::Kernel.3pm
Installing /home/vivek/perl5/man/man3/POE::Loop.3pm
Installing /home/vivek/perl5/man/man3/POE::Resource.3pm
Installing /home/vivek/perl5/man/man3/POE::Filter::Map.3pm
Installing /home/vivek/perl5/man/man3/POE::Resource::SIDs.3pm
Installing /home/vivek/perl5/man/man3/POE::Loop::IO_Poll.3pm
Installing /home/vivek/perl5/man/man3/POE::Pipe::TwoWay.3pm
Appending installation info to /home/vivek/perl5/lib/perl5/x86_64-linux-gnu-thread-multi/perllocal.pod
  RCAPUTO/POE-1.367.tar.gz
  /usr/bin/make install  -- OK
  RCAPUTO/Acme-POE-Tree-1.022.tar.gz
  Has already been unwrapped into directory /home/vivek/.cpan/build/Acme-POE-Tree-1.022-uhlZUz
  RCAPUTO/Acme-POE-Tree-1.022.tar.gz
  Has already been prepared
Running make for R/RC/RCAPUTO/Acme-POE-Tree-1.022.tar.gz
cp lib/Acme/POE/Tree.pm blib/lib/Acme/POE/Tree.pm
Manifying 1 pod document
  RCAPUTO/Acme-POE-Tree-1.022.tar.gz
  /usr/bin/make -- OK
Running make test
PERL_DL_NONLAZY=1 "/usr/bin/perl" "-MExtUtils::Command::MM" "-MTest::Harness" "-e" "undef *Test::Harness::Switches; test_harness(0, 'blib/lib', 'blib/arch')" t/*.t
t/01_basic.t .. ok   
All tests successful.
Files=1, Tests=2,  6 wallclock secs ( 0.09 usr  0.03 sys +  0.53 cusr  0.06 csys =  0.71 CPU)
Result: PASS
  RCAPUTO/Acme-POE-Tree-1.022.tar.gz
Tests succeeded but one dependency not OK (Curses)
  RCAPUTO/Acme-POE-Tree-1.022.tar.gz
  [dependencies] -- NA

Show Christmas tree in the shell

Simply type the following command:

## perl one liner to show Xmas tree ##
perl -MAcme::POE::Tree -e 'Acme::POE::Tree->new()->run()'

Sample outputs:

Gif 01: An animated christmas tree in Perl

Gif 01: An animated christmas tree in Perl

Tree customization

Here is my tree.pl:

#!/usr/bin/perl
# Use cpan module that we installed                
use Acme::POE::Tree;
my $tree = Acme::POE::Tree->new(
{
  star_delay => 1.5,  # shimmer star every 1.5 sec
  light_delay => 2,   # twinkle lights every 2 sec
  run_for => 10,      # automatically exit after 10 sec
}
);
$tree->run();

Now can play with your tree modifying star_delay, run_for, and light_delay. And ,there you have it a a Christmas tree in your shell for fun.

Not a fan of Perl? Try BASHTree

You can create animated Christmas tree in bash shell running on a Linux, macOS, *BSD, and Unix-like system. Use the wget command to grab the source code:
$ wget https://github.com/sergiolepore/ChristBASHTree/raw/master/tree-EN.sh
Run it as follows:
$ bash tree-EN.sh
Sample outputs:

Gif.02: An animated Christmas tree in Bash for Linux/Unix/macOS desktop

Gif.02: An animated Christmas tree in Bash for Linux/Unix/macOS desktop

Snow in you screen gnome desktop

Install gsnow gnome extension to snow on your desktop. Open Ubuntu app store and search for gsnow:
Search for gsnow on Gnome Linux desktop
Click on the extension and select INSTALL
Install gsnow on Linux
Once installed you can see snow on your desktop:

gsnow

gsnow in action (click to enlarge)

Conclusion

I hope you liked this Yule/Christmas tree. Happy holidays. If you enjoyed this desktop fun app, you may also like to use the following apps on Linux:

🐧 Get the latest tutorials on SysAdmin, Linux/Unix, Open Source & DevOps topics via:
CategoryList of Unix and Linux commands
File Managementcat
FirewallCentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network Utilitiesdig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNCentOS 8 Debian 10 Firewall Ubuntu 20.04

ADVERTISEMENTS
9 comments… add one
  • spiros Dec 8, 2015 @ 18:59

    After Gif 01, I think you meant to say “Tree customization” instead of “Teee customization”. Nice cristmass tutorial though :-)

  • svennson56 Dec 8, 2015 @ 20:11

    Nice find, in the shell script you miss ->run(); though :)

  • Edward Crosby Dec 9, 2015 @ 11:06

    Just a tip for those wanting to run on Fedora: I had to install perl-Curses for this to work for me.

  • fred Dec 11, 2015 @ 10:20

    Hi,
    thx for the script but I have an error on Manjaro:

    Test Summary Report
    ——————-
    t/01_basic.t (Wstat: 7424 Tests: 1 Failed: 1)
    Failed test: 1
    Non-zero exit status: 29
    Parse errors: Bad plan. You planned 2 tests but ran 1.
    Files=1, Tests=1, 0 wallclock secs ( 0.02 usr 0.00 sys + 0.02 cusr 0.00 csys = 0.04 CPU)
    Result: FAIL
    Failed 1/1 test programs. 1/1 subtests failed.
    Makefile:852 : la recette pour la cible « test_dynamic » a échouée
    make: *** [test_dynamic] Erreur 29
    RCAPUTO/Acme-POE-Tree-1.022.tar.gz
    /usr/bin/make test — NOT OK
    //hint// to see the cpan-testers results for installing this module, try:
    reports RCAPUTO/Acme-POE-Tree-1.022.tar.gz

    • duc Dec 25, 2016 @ 15:42

      I got them same error worked after run

      `sudo perl -MCPAN -e ‘install POE’ `

      and then

      `sudo perl -MCPAN -e ‘install Acme::POE::Tree’`

      merry christmas :D

  • David Fernández Piña Dec 14, 2015 @ 13:48

    If you are behind a proxy, call cpan, then o conf init /proxy/ enter http://:, as stated, e.g. here: https://stackoverflow.com/questions/11541428/using-cpan-with-a-proxy-failing-after-o-conf-init-proxy
    Remember to o conf commit.

  • David Fernández Piña Dec 16, 2015 @ 11:47

    Tested also on Windows 7 with Cygwin. It works well.

Leave a Reply

Your email address will not be published. Required fields are marked *

Use HTML <pre>...</pre>, <code>...</code> and <kbd>...</kbd> for code samples.