Yet Another Random Wallpaper Changer

Here’s yet another utility that, yep, you guessed it, is written in perl called chreli-randomwall. As the name implies, it’s random (keyword) wallpaper changer for desktop environments such as Openbox.

Requirements

The following are required for chreli-randomwall:

  • x11-xserver-utils (needed for xrandr)
  • nitrogen

The following are required for chreli-randomwall-hsetroot:

  • x11-xserver-utils (needed for xrandr)
  • hsetroot

Installation

To install, download chreli-randomwall_1.1.20170522.deb or chreli-randomwall-hsetroot_1.0.20170527.deb and execute the following command:

Disclaimer: 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.

sudo /usr/bin/dpkg -i chreli-randomwall_1.1.20170527.deb

Or

sudo /usr/bin/dpkg -i chreli-randomwall-hsetroot_1.0.20170527.deb

Usage

For Openbox, add the following, for example in ~/.config/openbox/autostart:

sleep 2 && /usr/bin/chreli-randomwall &

Or

sleep 2 && /usr/bin/chreli-randomwall-hsetroot &

The above will start chreli-randomwall upon login to Openbox.

Configuration

Upon initial execution of chreli-randomwall, it will create and set defaults in ~/.config/chreli-randomwall/chreli-randomwall.conf:

# chreli-randomwall 1.1.20170527
#
# configuration file for chreli-randomwall

# interval (in seconds) to change wallpaper
# default: 300
chreli-randomwall.interval=300

# directories to search for images
#  o comma separate for multiple directories
# default: /home/cygnus/Pictures
chreli-randomwall.image.dirs=/home/cygnus/Pictures,/home/cygnus/pics

The default interval (when to change the wallpaper) is 300 seconds (5 minutes). The default directory to look for images is ~/Pictures. If there is a desire to use multiple directories, that can be accomplished by a comma separated list. Any new images that are added while chreli-randomwall is running will be used the next time it re-reads the image dir(s), which it does after it cycles though showing all the images. This could take a while depending on how many images are involved. For the impatient, the process id for chreli-randomwall can be killed off and started again; be sure to send it background.

As stated earlier, chreli-randomwall randomly change the wallpaper. Meaning that if you have 100 unique images, once you see the first one, you should not see it again until the other 99 are displayed; unless, of course, you have the same image multiple times in the directory with a different file name.

If you have multiple monitors (who doesn’t, right), chreli-randomwall will detect (via xrandr)that too and update ~/.config/nitrogen/bg-saved.cfg as shown in the example below:

[xin_-1]
file=/home/cygnus/Pictures/c62314c087379a9f2306412ca4268925.jpg
mode=0
bgcolor=#242424
[:0.0]
file=/home/cygnus/Pictures/c62314c087379a9f2306412ca4268925.jpg
mode=0
bgcolor=#242424

The current version of chreli-randomwall will show the same image on all monitors that may be configured. A future release may allow for a different image on each screen.

And that’s all I have to say about that.

Posted in Geek, Linux, PERL, Scripting | Tagged , , , , , , , | Leave a comment

Yet Another Series

The previous posts were titled Yet Another …, which is to say that instead of using what was probably out there already, I took it upon myself to do it the way I wanted and to share.

And that’s all I have to say about that.

Posted in Geek, Linux, PERL, Programming, Scripting | Leave a comment

Yet Another Openbox Pipe-Menu Generator

If you ever used the openbox-menu command and it doesn’t work, chreli-ob-menu is a reasonable alternative (I could have a biased opinion on that though). It is yet another simple perl script (perl is your friend, embrace it) that programmatically reads .desktop files in /usr/share/applications and ~/.local/share/applications and generates <openbox_pipe_menu> entries when called from ~/.config/openbox/menu.xml. It is also cognizant of new applications that are installed.

Installation

Download chreli-ob-menu_1.0.20160923.deb and execute the following:

Disclaimer: 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.

sudo /usr/bin/dpkg -i chreli-ob-menu_1.0.20160923.deb

Usage

chreli-ob-menu [options]

Options:
    -a|--all                        generate pipe-menu for all categories
    -c|--category <category>        category to generate pipe-menu for
    -l|--list                       lists categories

    -h|--help                       display this help message
    -v|--version                    display version

Listing Supported Categories

chreli-ob-menu -l
Valid Categories:
 o Accessories
 o Development
 o Emulator
 o Game
 o Graphics
 o Internet
 o Multimedia
 o Office
 o Other
 o Preferences
 o System

Example Usage: Specific Category

<menu execute="/usr/bin/chreli-ob-menu -c System" id="openbox-System" label="System" icon="" />

The above will create a sub-menu called System with those applications using the category of System. If openbox has been compiled to show icons with menus, you can include the icon parameter that points to the image you would like to use.

Example Usage: All Categories

If you want to take the lazy approach and just have all the categories generate, you can do so by adding the following to ~/.config/openbox/menu.xml:

<menu execute="/usr/bin/chreli-ob-menu -a" id="desktop-all-menu" label="Menu" icon=""/>

Again, if openbox was compiled to include an icon with the menu items, you can give the icon parameter a value.

If you want just a static menu, you can call /usr/bin/chreli-ob-menu from the command line and copy-n-paste the output into ~/.config/openbox/menu.xml. You will, however, lose the dynamic capability when new applications are installed.

The chreli-ob-menu utility will do its level best to display icons to menu entries, including sub-menus, based on the gtk-icon-theme-name setting in ~/.gtkrc-2.0.

And that’s all I have to say about that.

Posted in Geek, Linux, PERL, Programming, Scripting | Tagged , , , , , | Leave a comment

Yet Another Simple Update Notifier

If you’re using a debian-based distro (such as Ubuntu or Linux Mint; both of which I view as Linux for Apple for Microsoft GUI babies either too lazy or afraid to use a terminal) or some derivative of RedHat (such as Fedora or CentOS) you may or may not have a systray applet that lets you know package updates are available. Below is a simple script, for debian-based installations, that will do just that.

The utility, chreli-update-check, written in Perl, leverages aptitude and yad (yet another dialog).

The aptitude command is as follows:

/usr/bin/aptitude search "~U" | /usr/bin/wc -l
3

The above instructs aptitude to search for upgradable packages (~U is shorthand) and is piped to the wc -l command to get the number of lines returned. You can read more about aptitude search terms here.

If you want to see what’s available to be updated, simply remove the | /usr/bin/wc -l from the above command:

/usr/bin/aptitude search "~U" 
i A libmenu-cache-bin    - LXDE implementation of the freedesktop Menu's cache (libexec)              
i A libmenu-cache3       - LXDE implementation of the freedesktop Menu's cache                        
i   pcmanfm              - extremely fast and lightweight file manager

If chreli-update-check detects updates (greater than 0 [zero]), it will construct the yad command to either display an in-your-face dialog: or a more subtle systray icon (displays details when moused over): The determination of either behavior is controlled by the chreli-update-check.nofification setting in ~/.config/chreli-update-check/chreli-update-check.conf; default is dialog.

To install chreli-update-check simply download chreli-update-check_1.0.20170520.deb and execute the following:

Disclaimer: 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.

sudo /usr/bin/dpkg -i chreli-update-check_1.0.20170520.deb

Once installed, simply execute:

/usr/bin/chreli-update-check

To schedule its execution, add the following to your crontab:

15 */4 * * * DISPLAY=:0 /usr/bin/chreli-update-check > /dev/null 2>&1

The above will execute 15 minutes past, every 4 hours; you can adjust as you deem necessary.

The initial time chreli-update-check executes, it will create a chreli-update-check.conf in ~/.config/chreli-update-check with default settings for which icon to use (chreli-update-check.icon) and what type of notification (chreli-update-check.nofification):

# chreli-update-check 1.0.20170520
#
# configuration file for chreli-update-check

# icon to use for dialog or systray
# default: /usr/share/icons/Adwaita/16x16/apps/system-software-update.png
chreli-update-check.icon=/usr/share/icons/Adwaita/16x16/apps/system-software-update.png

# type of notification
# legal values:
#  o systray: displays icon in systray
#  o dialog : displays dialog
# default: dialog
chreli-update-check.nofification=systray

Adjust to your needs.

And that’s all I have to say about that.

Posted in Geek, Linux, PERL, Scripting | Tagged , , , , , , , , , , , , , | Leave a comment

Website Weather Integration

Here’s a quick tutorial on how to integrate your own, near real-time weather stats into your website. There are sites, such as AccuWeather (who should, in all honesty, change their name) and Weather Underground, that will do this for you, but I find that you’re 1) beholden to their style and 2) not very accurate. The Weather Underground one for example will say one thing on your site but when you click the sticker (that’s what they call it) it says a completely different thing; their mobile app does the same thing. As with any of these sites that provide weather information, unless you live right next to where they have their sensors set up (typically the closest airport), the readings are likely to be off. This tutorial will be using NOAA, so let’s get started.

What you’ll need first is your location, latitude and longitude. There are a number of sites that you can get that information from; this one works.

Next, you’ll need to download weather.js (right-click save-as) and change the lat & lon variables to your location.

/**
 * Change to your location. The below is Washington D.C.
 */
var lat = '38.907192';
var lon = '-77.036871';

Then add the following to the page you want to integrate weather into by adding a DIV element with the id of weather, like so:

<div id="weather"></div>

Towards the end of your page, before the <body> tag, add the following:

<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="weather.js"></script>
<script>
    <!--
    $(document).ready(function() {
        // get initial weather
        getWeather();
        // refresh every 15 minutes; 900 * 1000
        setInterval(function() { getWeather(); }, 900000);
    }
    -->
</script>

The above will result in something like the below that will automatically update every 15 minutes.

The following CSS was used to style the current conditions icon:

#weather-icon {
    -webkit-border-top-left-radius:5px;
    -moz-border-radius-topleft:5px;
    border-top-left-radius:5px;
    -webkit-border-top-right-radius:5px;
    -moz-border-radius-topright:5px;
    border-top-right-radius:5px;
    -webkit-border-bottom-right-radius:5px;
    -moz-border-radius-bottomright:5px;
    border-bottom-right-radius:5px;
    -webkit-border-bottom-left-radius:5px;
    -moz-border-radius-bottomleft:5px;
    border-bottom-left-radius:5px;
    border: 1px solid #b0b0b0;
}

And that’s all I have to say about that.

Posted in Geek, JavaScript, jQuery | Tagged , , , , , , , , , , , | Leave a comment