.. sectnum:: :depth: 7 ############# tausta.ksh.sh ############# ********************************************************************** Korn Shell script, that change desktop wallpaper under X Window System ********************************************************************** .. contents:: :backlinks: entry Copyright and licence ##################### Copyright (C) 2003–2013 Juhapekka Tolvanen and Mika Jorma Saaristo This script was originally created as a Bourne Shell script by: Mika Jorma Saaristo http://www.cc.jyu.fi/~mjsaaris/ ``mjsaaris (at) cc (dot) jyu (dot) fi`` After that it was heavily modified by: Juhapekka ”naula” Tolvanen http://iki.fi/juhtolv ``juhtolv (at) iki (dot) fi`` A function called “watcher” is based on a Perl-code-snippet as seen in a man page of ``xscreensaver`` -command (by Jamie Zawinski ( http://www.jwz.org/ )) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Also this documentation-file is under GNU GPL version 2 or (at your option) any later version. Source code is file ``README.tausta.txt`` and everything that is generated from it is treated like binary of software. Some help-files that are used to generate different documentation files, may have different licensing. They are mostly in public domain. See commented lines in the beginning of each such file. Notes ##### Pros and cons of this software ****************************** Pros ==== Main advantage of this software is extreme flexibility. Practically any command that can change your desktop wallpaper or otherwise manipulate background of your desktop, can be used by this software. This software tries to avoid loading wallpaper when XScreenSaver is running some of its screen hacks. You do not need Mad Shell-Fu Skillz for configuring this software. Cons ==== If you do not want to change desktop wallpaper automatically after every few hours, this software is definitely not for you. If you want to change your desktop wallpaper after every few hours, but do not need all this flexibility, this software may be a little bit overkill for you. Some Bourne Shell -scripting skills are needed when configuring this software and for some people it is too much (but as I said before, you do not need Mad Shell-Fu Skillz) Other notes *********** In my machine a command called ``ps`` is from software package called ``procps``. If you use some GNU/Linux-distribution, you probably have it. I have not tested, how well these scripts work with other implementations of ``ps``-command. ``tausta.sh`` script is written in plain Bourne Shell -language; Unfortunately it is not as reliable as ``tausta.ksh.sh`` : I have seen too many times, that ``tausta.sh`` scripts loads wallpaper when that xscreensaver runs some screen hack. If you experience same problem, install some implementation of Korn Shell -language (ie. ``pdksh``, ``mksh`` or ``zsh``) and use ``tausta.ksh.sh`` instead. In fact, I do not bother to maintaining ``tausta.sh`` anymore; I do not keep its features and bug fixes in sync with ``tausta.ksh.sh`` . Most proprietary Unix's has at least AT&T ``ksh88``. Some of them has ``dtksh``; It is ``ksh93`` with CDE-capabilities. ``pdksh`` has tinier binary than ``zsh``, so you’d better use it as implementation of Korn Shell-language. ``pdksh`` is full of bugs, but those bugs should not affect using this software. There is also so called ``mksh``; it is based on source code of ``pdksh``, but its authors have fixed its bugs. If you use ``zsh`` as Korn Shell-implamentation, you must make it emulate ksh with this command:: emulate ksh The Original AT&T KSH93 is finally really free software, so feel free to use it: http://www.kornshell.com/ At least Debian GNU/Linux and Slackware Linux have it packaged already. It seems, this script is most reliable, when you use the original AT&T KSH93 as your Korn Shell -implementation. Also ``mksh`` seems to work just fine. Installation ############ First you need some cool software, that can load wallpaper or image to X Window System desktop. I prefer ``xli`` and ``hsetroot``. If I want to download some frequently updated image from WWW and load it as wallpaper, I prefer ``dog`` for that purpose, but ``curl`` is also good. This software also tries to use ``gxmessage`` for showing error messages in dialog. If it is not available, it will use just old ``xmessage`` , instead. Create directory ``~/.tausta.sh.dir`` . ``tausta.rc.sh`` has some user-serviceable parts you can edit; at least name of window manager process must be right or script won’t run at all. Put that file called ``tausta.rc.sh`` to ``~/.tausta.sh.dir/`` . Put a script called ``tausta.sh`` or ``tausta.ksh.sh`` to some directory in your ``$PATH`` , for example ``~/bin/`` . You may need to edit them a little bit, first. Use ``chmod`` -command to ensure that you can run it. Now create some file called ``tausta.conf`` and put it to ``~/tausta.sh.dir`` . A file called ``tausta.conf`` is provided as example. Empty lines and lines starting with ``#`` are ignored, of course. Commands are normal commands that Bourne Shell or any of its derivative understands. You can use exported environment variables instead of plain commands and directory paths. All those environment variables are exported in a file called ``~/tausta.sh.dir/tausta.rc.sh`` . You can unsort lines of ``tausta.conf`` with software like ``rl`` , ``unsort`` or ``bogosort``. Now everything should be in place. Then you must configure your X-session, window manager or desktop environment so, that command like this is run automatically during startup:: nice -n 20 tausta.ksh.sh & If your computer is powerfull enough, you can omit that ``nice -n 20``, of course. You can stop waiting for next loading of wallpaper with commands like these:: kill -USR1 $(cat ~/.tausta.sh.dir/tausta.pid) :: kill -USR1 `cat ~/.tausta.sh.dir/tausta.pid` Feel free to bind them to some menu entry, panel button, keybinding etc. After giving such command, you must wait about amount of ``$CHECKINTERVAL`` seconds before the next wallpaper is loaded. Use signal ``SIGHUP``, ``SIGINT``, ``SIGQUIT`` or ``SIGTERM`` to stop script, so it can safely exit. You can restart script with signal ``SIGUSR2`` . Restarting is needed, if you edit ``tausta.rc.sh`` while running this software. If you edit ``tausta.conf`` , there is no need to restart this software. If some image loading command makes your desktop background messed up, or any other anomalies are seen, then check out file ``~/.tausta.sh.dir/lastcommand`` to find out which command was tried when loading the latest image. That file is also useful, if you think that latest loaded wallpaper is boring and you want to stop using it. Please, remember that command ``killall sleep`` is not a good way to stop waiting for the next image-loading command: You must be sure you do not have any other ``sleep`` -command running. Commands for loading wallpapers or other desktop background manipulation ######################################################################## Software ******** Consult these, if you can’t find some software: - http://freecode.com/ (A website formerly know as freshmeat.net) - http://www.ftpsearch.net/ - http://www.google.com/ For loading wallpapers ====================== - feh (This is really an image viewer, but it can load images to root window and download them from WWW.) - http://feh.finalrewind.org/ - hsetroot (Best software for loading center-tiled. Homepage is under maintenance mode. Pristine source code is still available in FTP-site of Debian and its mirrors.) - http://thegraveyard.org/hsetroot.php - ftp://ftp.debian.org/debian/pool/main/h/hsetroot/hsetroot_1.0.2-3.debian.tar.gz - ftp://ftp.debian.org/debian/pool/main/h/hsetroot/hsetroot_1.0.2.orig.tar.gz - http://www.debian.org/mirror/list - qiv (This is really an image viewer, but it can load images to background, too. It can read also SVG-files and some other vector graphic files, too.) - http://spiegl.de/qiv/ - xli (Good for all but loading wallpaper center-tiled. Homepage has been disappeared. Pristine source code is still available in FTP-site of Debian and its mirrors.) - http://pantransit.reptiles.org/prog/ - ftp://ftp.debian.org/debian/pool/main/x/xli/xli_1.17.0+20061110.orig.tar.gz - http://www.debian.org/mirror/list - xloadimage (has ``xsetbg``). YOU DO NOT NEED THIS CRAP!: Use ``xli``, because it is improved version of xloadimage. ``xloadimage`` is likely to be present on any X11 contrib mirror site: - http://www.mirrormonster.com/ftp.x.org/R5contrib/xloadimage.4.1.tar.gz - http://www.x.org/mirrors.html - chbg (This is buggy crap that depends on ancient and obsolete GTK+ 1.* . Homepage URL do not work, anymore.) - http://chbg.sourceforge.net/ - Esetroot (This is mostly for users of Enlightenmet -window manager. Homepage URL do not work, anymore.) - http://www.jnrowe.ukfsn.org/projects/esetroot.html For loading desktop wallpaper from many files ============================================== - habak (I haven’t tried this. Homepage has been disappeared. Pristine source code is still available in FTP-site of Debian and its mirrors.) - ftp://ftp.debian.org/debian/pool/main/h/habak/habak_0.2.5.orig.tar.gz - http://www.debian.org/mirror/list - telak (I haven’t tried this. This is a small tool to draw local or remote pictures on your root window.) - http://julien.danjou.info/projects/telak For loading planet or moon images ================================= - xplanet. - http://xplanet.sourceforge.net/ - xphoon - http://xphoon.sourceforge.net/ - http://sourceforge.net/projects/xphoon/ - http://www.acme.com/software/xphoon/ - pngphoon. - http://svolli.de/software/pngphoon/ For making (random) pics (on the root window) ============================================= - xstarfish - http://www.redplanetsw.com/starfish - Evolvotron (I haven’t tried this yet, but it seems promising. Maybe you should create images with this software by hand and then load them with ``xli`` or ``hsetroot``) - http://www.bottlenose.demon.co.uk/share/evolvotron/ - Randim (I haven’t tried this yet, but it seems promising. It is “interactive fractal image generation program based on the theory of iterated function systems”.) - http://interstitiality.net/ifs_f.html - xtartan (Can draw tartan patterns on root window). - ftp://ftp.x.org/contrib/applications/xtartan-* - XBanner (This is for XDM, but it may be useful for desktop, too. I haven’t tried this, yet.) - http://www.hijinks.com/~spade/linux/XBanner/ For changing color of desktop background ======================================== - xsetroot (At least in Debian GNU/Linux binary of this command belongs to a package called ``x11-xserver-utils`` .) - http://xorg.freedesktop.org/releases/individual/app/ For unsorting lines of ``tausta.conf`` ====================================== - bogosort - http://www.lysator.liu.se/~qha/bogosort/ - GNU coreutils (Version 6.0 and above includes ``shuf``) - http://www.gnu.org/software/coreutils/ - msort (It has random sorting as one of its comparison types) - http://billposer.org/Software/msort.html - rl (randomize lines) - http://arthurdejong.org/rl/ - unsort - http://www.vanheusden.com/unsort/ You’d better learn this feature of your text editor: How to pipe chosen lines of text to external command and then substitute those lines with output of that command. If your text editor can’t do it, it’s time to learn some better text editor, like vi, Vim, GNU Emacs, XEmacs or SXEmacs. Learn to use “undo”, too. For fetching files from WWW =========================== - dog (This is probably the fastest software for this purpose, because it has the smallest binary. But it has been reported to have ugly source code. This program can not handle redirection at all. Hence, it needs direct URL. Homepage has been disappeared. Pristine source code is still available in FTP-site of Debian and its mirrors) - http://jl.photodex.com/dog/ - ftp://ftp.debian.org/debian/pool/main/d/dog/dog_1.7.orig.tar.gz - http://www.debian.org/mirror/list - feh (This is really an image viewer, but it can load images to root window and download them from WWW. Very handy, because you do not need piping.) - http://feh.finalrewind.org/ - snarf (Has smaller binary than ``curl``. In fact it is just a little bit bigger than binary of ``dog``. Very recommended.) - http://www.xach.com/snarf/ - curl (Much smaller binary than in ``wget``. Available in most Linux-distributions and very commonly found in many Unix-workstations. Very recommended; oriented towards downloading just one file. This is also available as a library: With that library it is easy to add downloading features to almost any software. BTW feh uses those libraries.) - http://curl.haxx.se/ - wget. (Available in most Linux-distributions. Not too bad, but oriented towards downloading whole directories or other bigger entities. It has bigger binary than ``curl``.) - http://www.gnu.org/software/wget/wget.html - httpie (It claims to be “cURL-like tool for humans”, but you must have new enough version, at leat 0.3.1.) - http://httpie.org - https://github.com/jkbr/httpie - lynx. (This is really a WWW-browser) - http://lynx.isc.org/ - w3m. (This is really a WWW-browser) - http://w3m.sourceforge.net/ - links / elinks / links2 / links hacked / whatever. (These are really WWW-browsers. Argh… I just do not bother telling homepages of all those forks. Just use Google and Wikipedia and be happy.) - http://en.wikipedia.org/wiki/Links_%28web_browser%29 - C-Kermit (Old program that can also act as replacement for programs like wget or curl. It can do file transfer, terminal emulation, character set conversion and many other things.) - http://www.kermitproject.org/ Commands ******** Especially I tell you how to substitute ``xv``-commands with free software. Beginning of commands ===================== :: xv -smooth +noresetroot -root -quit :: xli -quiet -onroot Tiled ===== :: xv -smooth +noresetroot -root -quit /usr/local/textures/3com01.jpg :: xli -quiet -onroot /usr/local/textures/3com01.jpg :: feh --bg-tile /usr/local/textures/3com01.jpg :: qiv -y /usr/local/textures/3com01.jpg :: qiv --root_t /usr/local/textures/3com01.jpg Double size tiled ================= :: xli -quiet -onroot -zoom 200 /usr/local/textures/3com01.jpg Center tiled ============ :: xv -smooth +noresetroot -root -rmode 4 -quit \ /usr/local/textures/applix01.jpg :: hsetroot -tile /usr/local/textures/applix01.jpg chbg -mode centertile /usr/local/textures/applix01.jpg Centered ======== :: xv -smooth +noresetroot -root -rmode 5 -quit \ /usr/local/textures/stickdeath01.jpg :: xli -quiet -onroot -center -border black \ /usr/local/textures/stickdeath01.jpg :: hsetroot -center /usr/local/textures/stickdeath01.jpg Centered with black borders:: xli -quiet -onroot -center -border black \ /usr/local/textures/stickdeath01.jpg :: hsetroot -solid '#000000' -center :: feh --bg-center /usr/local/textures/3com01.jpg :: qiv -x /usr/local/share/textures/escher18.png :: qiv --root /usr/local/share/textures/escher18.png Centered with white borders:: xli -quiet -cdither -onroot -center -border white :: hsetroot -solid '#ffffff' -center Double size pic. Centered. White borders:: xli -quiet -onroot -center -zoom 200 -border white Double size pic. Centered. Black borders:: xli -quiet -onroot -center -zoom 200 -border black Maximized: Stretch image to fill whole screen ============================================= :: xv -smooth +noresetroot -root -max -quit \ /usr/local/textures/soundbla.jpg :: hsetroot -fill /usr/local/textures/soundbla.jpg :: xli -quiet -onroot -fillscreen -border black \ -smooth /usr/local/textures/soundbla.jpg :: feh --bg-scale /usr/local/textures/soundbla.jpg :: qiv -z /usr/local/textures/soundbla.jpg :: qiv --root_s /usr/local/textures/soundbla.jpg Maximized: Stretch image, but keep aspect ratio =============================================== :: hsetroot -full /usr/local/textures/soundbla.jpg :: xli -quiet-onroot -fullscreen -border black \ -smooth /usr/local/textures/soundbla.jpg :: feh --bg-max /usr/local/textures/soundbla.jpg Solid background color and no image =================================== :: xsetroot -solid SOMECOLOR That color can be for example “salmon” (or any other color mentioned in ``rgb.txt`` -file of your X Window System) or RGB value in hex, for example ``#000000`` (black) . ``xsetroot`` can do other background manipulations, too. With this command it creates grid sized 16×16 pixels and its foreground color is LightSalmon and background color is MidnightBlue:: xsetroot -mod 16 16 -fg LightSalmon -bg MidnightBlue Often updated WWW-image ======================= (Don’t blame me, if such image is one day replaced with goatse or tubgirl or if some goatse-like guy starts doing his thing in front of some webcam…) dog can not handle redirection. hsetroot can not read from stdin. :: dog --no-header http://vision.ucsd.edu/~atai/softwarewar.png \ | xsetbg -quiet -onroot -center stdin :: feh --bg-max http://www.ssec.wisc.edu/data/comp/latest_moll.gif :: dog --no-header http://www.ssec.wisc.edu/data/comp/latest_moll.gif \ | xsetbg -quiet -onroot -fullscreen stdin :: dog --no-header http://www.ssec.wisc.edu/data/comp/latest_moll.gif \ | xli -quiet -cdither -onroot -fullscreen -border black -smooth \ stdin :: snarf http://www.ssec.wisc.edu/data/comp/latest_moll.gif - \ | xsetbg -quiet -onroot -fullscreen stdin :: curl -s http://vision.ucsd.edu/~atai/softwarewar.png \ | xsetbg -quiet -onroot stdin :: wget -q -O - http://vision.ucsd.edu/~atai/softwarewar.png \ | xsetbg -quiet -onroot -center stdin :: lynx --source --dump http://vision.ucsd.edu/~atai/softwarewar.png \ | xsetbg -quiet -onroot -center stdin :: elinks -dump -source http://iki.fi/juhtolv/pix/ryppy_black.jpg \ | xsetbg -quiet -onroot stdin :: w3m -dump_source http://iki.fi/juhtolv/pix/ryppy.jpg \ | xsetbg -quiet -onroot stdin :: # This is command of HTTPie http --body GET \ http://www.ssec.wisc.edu/data/comp/latest_moll.gif \ | xli -quiet -cdither -onroot -fullscreen -border black -smooth stdin :: kermit -q -H -i -E -C \ 'HTTP /TOSCREEN GET http://www.ssec.wisc.edu/data/comp/latest_moll.gif , QUIT' \ | xli -quiet -cdither -onroot -fullscreen -border black -smooth stdin Phase of the moon etc. ====================== :: xphoon :: xplanet -config ~/.xplanet/config -longitude 25.5 -latitude \ 62.1 -label -num_times 1 -label_string "Origin: %o. Target: %t." \ -labelpos "+15+15" -pango -font 'Sans' -fontsize 12 :: xplanet -config ~/.xplanet/config -longitude 25.5 -label \ -num_times 1 -label_string "Origin: %o. Target: %t." \ -labelpos "+15+15" -pango -font 'Sans' -fontsize 12 -projection \ mercator :: xplanet -config ~/.xplanet/config -longitude 25.5 -label \ -num_times 1 -label_string "Origin: %o. Target: %t." -labelpos \ "+15+15" -pango -font 'Sans' -fontsize 12 -projection lambert :: xplanet -config ~/.xplanet/config -latitude 90 -label \ -num_times 1 -label_string "Origin: %o. Target: %t." -labelpos \ "+15+15" -pango -font 'Sans' -fontsize 12 -projection azimuthal :: xplanet -config ~/.xplanet/config -latitude -90 -label -num_times \ 1 -label_string "Origin: %o. Target: %t." -labelpos "+15+15" \ -pango -font 'Sans' -fontsize 12 -projection azimuthal :: xplanet -config ~/.xplanet/config -longitude 25.5 -label \ -num_times 1 -label_string "Origin: %o. Target: %t." -labelpos \ "+15+15" -pango -font 'Sans' -fontsize 12 -projection ancient :: xplanet -config ~/.xplanet/config -longitude 25.5 -label \ -num_times 1 -label_string "Origin: %o. Target: %t." -labelpos \ "+15+15" -pango -font 'Sans' -fontsize 12 -projection hemisphere :: xplanet -config ~/.xplanet/config -longitude 25.5 -latitude \ 62.1 -label -num_times 1 -label_string "Origin: %o. Target: %t." \ -labelpos "+15+15" -pango -font 'Sans' -fontsize 12 -projection \ orthographic Randomly generated pic ====================== :: xstarfish --size random :: xstarfish --size small :: xstarfish --size medium :: xstarfish --size large :: xstarfish --size full Doing it in Gnome way ===================== Set background image:: gconftool --type string --set \ /desktop/gnome/background/picture_filename \ /path/to/filename Image options (yes, separated command):: # Fill screen. Keep aspect ratio (in Gnome 2.16): gconftool --type string --set \ /desktop/gnome/background/picture_options scaled As I am writing this, that part ``picture_options`` can have one of these values: - none - wallpaper - centered - scaled - stretched You can check out which image options are available by doing this: Start up a program called ``gconf-editor``. See gconf-option ``/desktop/gnome/background/`` . AFAIK Gnome can use also SVG-files as a wallpaper. TODO #### Somebody please tell me, how to do this thing: - How to manipulate background of Plasma of KDE via command line? About this document ################### This document is originally written in lightweight markup language called “reStructuredText”. It is written in a file called ``README.tausta.txt``. If you want to edit it and then re-generate other formats of this document, you must first install a software package called ``python-docutils``. Bourne Shell -script called ``compileall.sh`` generates HTML and LaTeX. HTML-file is ready for any WWW-browser. LaTeX-version is compiled with ``xelatex`` to create PDF-file. You’d better have quite decent TeX-distribution, or that compilation of LaTeX-file will fail. I use TeX Live. Then PDF-file is converted to PostScript with a command called ``pdftops`` (belongs to ``poppler-utils``). You can get even more exotic file formats (for example EPUB), if you install more software and then edit ``compileall.sh``. Especially you need Calibre and ``pandoc``. A file called ``cleanall.sh`` removes all generated files and all their auxiliary and temporary files. .. ================================================================= .. This is not just a text file! This is also reStructuredText -file! .. You can convert this file to many formats with python-docutils .. http://docutils.sourceforge.net/ .. http://docutils.sourceforge.net/rst.html .. Markup and hierarchy of titles, subtitles, sub-sub-titles etc. .. ######## .. ******** .. ======== .. ++++++++ .. -------- .. ........ .. ================================================================= .. Help for text editors: .. For Emacs: .. Local Variables: *** .. mode: rst *** .. coding: utf-8 *** .. End: *** .. For Vim: .. vim: set ft=rst fenc=utf-8 fdm=marker :