Thursday, March 31, 2016

Rotating wallpapers

I got the wallpaper to change when I log on.  Minor fix to the command when starting up.  You start with 'Preferences' then pick 'Default applications for LXSessions'.  Click on the Autostart and create an entry like shown in the screen print.
LXSession settings


Shell command to rotate wallpaper





I then followed this up by seeing if I can put it into cron.  I did 'cron -e' from a command window and set it up to run every minute so I can see if would work.  Minutes passed and nothing happened.  I put in debug code to get the return code from pcmanfm and put it to a file.  Looking at the file I could see a return code of 1 so I knew that there was an error somewhere.  I check on-line and found an answer in stackoverflow.  I made a minor change in my script and it worked!  I reset cron to update it every 10 minutes and it still works.
cron settings to change wallpaper every 10 minutes

Bash script to change wallpaper

Monday, March 28, 2016

LINUX Bash Script skeleton code

I have been writing very simple Bash scripts for several years.  They are not complex, but, they help me automate tasks at home and work.  If I have to do something more than once I prefer to have a script automate that task. Over the years I have found that there are a lot of excellent on-line sites with information that helped me do my scripts.

From time-to-time this blog will be updated with new/updated skeleton script.

One site that I like is for color in Bash echo commands and they helped me when I was starting my use of color in scripts.  Most of my scripts don't need color, but, now and then I like to highlight something.  UBUNTU has a great forum area and I found a very nice script that allows me to quickly and easily change my background image. The link is here.

One of the first tasks I do with a new machine using LINUX and Z/OS Unix is to create a script library and place my skeleton bash template in that library.  I won't post the one from work as that is specific to the Z/OS environment and the client I work for.  The one I am posting is my personal template. When I find that I am using a piece of bash code on a regular basis I put it into the template and make it easier for me to find that one piece in the future.

My skeleton bash script is below.  I try to work with a basic naming standard.  User defined variables start with "u" and subroutines start with "z".  Everyone has their preferences, but, this is one I have been using for years and I am comfortable with it.  Version is showing as one as I finally got around to putting comments in and I figured that 1.00.00 is a good place to start.

START OF BASH SCRIPT


#! /bin/bash

# This is a skeleton script that has some of my bash codes commonly used
# in my scripts.
#
# Version:  1.00.00 - 2016/03/28 - TPT.  Initial version.
#

# ANSI Colors
zSetANSI() {

# Foreground colors:
    uFGBK="\033[30m";   #Black
    uFGLRD="\033[31m";  #Low  Red
    uFGHRD="\033[91m";  #High Red
    uFGLGR="\033[32m";  #Low  Green
    uFGHGR="\033[92m";  #High Green
    uFGLYW="\033[33m";  #Low  Yellow
    uFGHYW="\033[93m";  #High Yellow
    uFGLBU="\033[34m";  #Low  Blue
    uFGHBU="\033[94m";  #High Blue
    uFGLMG="\033[35m";  #Low  Magenta
    uFGHMG="\033[95m";  #High Magenta
    uFGLCY="\033[36m";  #Low  Cyan
    uFGHCY="\033[96m";  #High Cyan
    uFGHGY="\033[37m";  #High Gray
    uFGLGY="\033[90m";  #Low  Gray
    uFGWT="\033[97m";   #White

# Background colors:   
    uBGBK="\033[40m";   #Black
    uBGLRD="\033[41m";  #Low  Red
    uBGHRD="\033[101m"; #High Red
    uBGLGR="\033[42m";  #Low  Green
    uBGHGR="\033[102m"; #High Green
    uBGLYW="\033[43m";  #Low  Yellow
    uBGHYW="\033[103m"; #High Yellow
    uBGLBU="\033[44m";  #Low  Blue
    uBGHBU="\033[104m"; #High Blue
    uBGLMG="\033[45m";  #Low  Magenta
    uBGHMG="\033[105m"; #High Magenta
    uBGLCY="\033[46m";  #Low  Cyan
    uBGHCY="\033[106m"; #High Cyan
    uBGLGY="\033[47m";  #Low  Gray
    uBGHGY="\033[107m"; #High Gray

# Underline:
    uFGULINE="\033[4m";
   
# Blink:
    uFGBLINK="\033[5m";
   
# Reset all:   
    uFGRESET="\033[0m"
}


#
#  Get the system clock and set to a variable.
#

zGetDATE() {

# System date.  For all date options type date --h on command line.

    uSYSYY=$(date +%Y);
    uSYSMM=$(date +%m);
    uSYSDY=$(date +%d);
    uSYSDT=$uSYSYY$uSYSMM$uSYSDY;
   
    uSYSHH=$(date +%H);
    uSYSMIN=$(date +%M);
    uSYSSEC=$(date +%S);
    uSYSTM=$uSYSHH$uSYSMIN$uSYSSEC;
   
    uSYSJDT=$(date +%j);
    uSYSWK=$(date +%W);
    uSYSDOW=$(date +%w);
    uSYSDAY=$(date +%A)   
    uSYSMTH=$(date +%B)
}

# ============================================================
# END OF ALL SUBROUTINES FOR THIS SCRIPT.
# ============================================================

zSetANSI;
zGetDATE;

# Define the working variable for return codes:
uRC=0;

# Get current directory name
uDir=$( cd "$( dirname "$0" )" && pwd);

# Get process ID
uProcID=$$


#  Now echo out the stuff to the console:

clear;
echo "${uFGHRD}Process Information${uFGRESET}";
echo ;
echo "  ${uFGLGR}Directory........: " $uFGHGR $uDir;
echo "  ${uFGLGR}Process id.......: " $uFGHGR $uProcID;
echo "  ${uFGLGR}Directory........: " $uFGHGR $LOGNAME;
echo ;
echo $uFGHRD;
echo "Date information:" $uFGRESET;
echo "  ${uFGLYW}uSYSDT...........: " $uFGHYW $uSYSDT;
echo "  ${uFGLYW}uSYSTM...........: " $uFGHYW $uSYSTM;
echo "  ${uFGLYW}uSYSJDT..........: " $uFGHYW $uSYSJDT;
echo "  ${uFGLYW}uSYSWK...........: " $uFGHYW $uSYSWK;
echo "  ${uFGLYW}uSYSDOW..........: " $uFGHYW $uSYSDOW;
echo "  ${uFGLYW}uSYSDAY..........: " $uFGHYW $uSYSDAY;
echo "  ${uFGLYW}uSYSMTH..........: " $uFGHYW $uSYSMTH;

echo $uFGRESET;
echo $uFGHYW;
echo "ANSI Foreground color codes:" $uFGRESET;
echo "  RED..............: ${uFGLRD}Low ${uFGHRD}HIGH" $uFGRESET;
echo "  GREEN............: ${uFGLGR}Low ${uFGHGR}HIGH" $uFGRESET;
echo "  YELLOW...........: ${uFGLYW}Low ${uFGHYW}HIGH" $uFGRESET;
echo "  BLUE.............: ${uFGLBU}Low ${uFGHBU}HIGH" $uFGRESET;
echo "  MAGENTA..........: ${uFGLMG}Low ${uFGHMG}HIGH" $uFGRESET;
echo "  CYAN.............: ${uFGLCY}Low ${uFGHCY}HIGH" $uFGRESET;
echo "  GRAY.............: ${uFGLGY}Low ${uFGHGY}HIGH" $uFGRESET;

echo ;
echo $uFGHYW;
echo "ANSI Background color codes:" $uFGRESET;
echo "  RED..............: ${uBGLRD}Low ${uBGHRD}HIGH" $uFGRESET;
echo "  GREEN............: ${uBGLGR}${uFGBK}Low ${uBGHGR}HIGH" $uFGRESET;
echo "  YELLOW...........: ${uBGLYW}${uFGBK}Low ${uBGHYW}HIGH" $uFGRESET;
echo "  BLUE.............: ${uBGLBU}Low ${uBGHBU}${uFGBK}HIGH" $uFGRESET;
echo "  MAGENTA..........: ${uBGLMG}Low ${uBGHMG}${uFGBK}HIGH" $uFGRESET;
echo "  CYAN.............: ${uBGLCY}Low ${uBGHCY}${uFGBK}HIGH" $uFGRESET;
echo "  GRAY.............: ${uBGLGY}${uFGBK}Low ${uBGHGY}HIGH" $uFGRESET;


echo ;
echo $uFGHYW;
echo "ANSI Other color codes:" $uFGRESET;
echo ;
echo "  UNDERLINE........: ${uFGULINE}Underline" $uFGRESET;
echo "  BLINK............: ${uFGBLINK}Blink" $uFGRESET;
echo ;
echo "Script finishing with return code: " $uRC;


exit $uRC;

# ----------  END OF SCRIPT ----------


Saturday, March 26, 2016

A week in and tweaking LUBUNTU to fit

Now that I have been using LUBUNTU for a week I am now tweaking the system to make it easier for me.  If there is something I do more than once I want to automate it, even if it is a one line command.

I created a couple of folders and dropped in shortcuts or scripts of what I do.  Nothing earthshaking, but, they make my life easier.  One folder are one line commands.  XTERM with settings I prefer to work with, midnight commander and top.  After I get it all tweaked to the way I want the next thing is to learn how to add these to the menu.  Can I improve the scripts, yes!  This is just the start.

My Tools folder for building desktop shortcuts

Desktop setup for midnight commander

Midnight commander with font/colors I prefer
Midnight commander
 
In windows you can do something similar with shortcuts, but, I like linux as I can tweak things to work in exactly the way I want with simple text files and bash.  As things go on I will be building more and more tools to automate my work.  I do this where I work and I have a large toolkit there that automates almost all of my mainframe work that I have to do on a regular basis.

Update 1 - 2016/03/27:

Yay, I found out how to add entries to the menu.  Right now it is to the Other folder, but, that is a good step.  I had to copy my applications to */.local/share/applications and they showed up in menu.


My Menu now shows my apps

~/.local/share/applications

Update 2 - 2016/03/28:

Minor update, I added KATE to my editors.  I like it as it is small, fast, light and does what I need a code editor to do.



Saturday, March 19, 2016

Why do I use ad blockers?

In this blog I will try to explain why I am using ad blocking software.  To quickly summarize use ad blocking software for four simple reasons.
  1. I have a bandwidth limit and when I exceed it I pay for every byte sent/received.
  2. A number of devices I use are older and slower and most ads will bring them to a complete stop.
  3. Ads have now been used to target us with malware.
  4. Cookies and other tools are being used to peel back what little privacy we have on-line to track us everywhere and try to target us with 'relevant' ads based on where we go.

For a number of years I have been using ad block software.  Publishers for years also have been complaining that we are stealing.  Frankly that is BULLSHIT, publishers you have been hogging my bandwidth that I pay for when you spew ads at me and try to track every move I make on-line.  I monitored a few sites and 80% of what is sent to me are scripts and images for ads and tracking companies!  That is just the scripts, I wasn't even counting the images and flash pages they were sending.  Since I am the one paying for the bandwidth I want to make sure I get what I pay for.  For the good sites with ads that are tasteful, unobtrusive and doesn't suck up every spare CPU cycle I white-list and allow the ads.  The rest I give them a try now and then and if I find them to be resource hogs I black-list again.

Some will say it isn't that bad, well in my not so humble opinion it is.  I have a number of devices and for all of them I must use ad blocking software or when I go to a site in the browser a number of my devices will stop for minutes at a time while it is trying to render that page and serve ads.  The three devices where I must use ad blocking or they are almost unusable are:
  1.  Huawei cell phone.  I use this now and then when i am out shopping.  While resting I may surf Twitter, Facebook and email if the mall has free WI-FI.  Now and then something may catch my eye on-line and I click the link to see more about it. Without ad blockers the browser will take minutes to render a page (looking at you CNN, ABC, CTV and CBC).  At times I just close the window due the scripts running if I don't use ad blockers.
  2. Google Nexus 7 tablet.  This is now retired, but, I used it in a similar manner to my cell phone when traveling.  At home it was my main tool for using Twitter, Facebook, blogging and email.  Like the phone I am forced to use ad blockers or even that machine will slow down to a near stop.
  3. Acer Aspire Net-book.  This is a more robust machine, albeit a low end laptop.  I upgraded the system to 2 gigs of memory, but, everything else is stock.  Before I moved to Linux I was running Windows 7 then Windows 10.  Like the two  devices before I do run ad blockers.  It isn't as bad as those devices, but, it would take up to a minute for some sites to render a page and I watched the CPU usage hit 100% (I like using GKRELLM to see what my system is doing).  I also modified my HOSTS file to kill a lot of ads and trackers.  
I have two more devices that are more modern and higher powered and even there I use ad blockers as even they have problems at times rendering pages with ads.
  1. Samsung Galaxy Tab A.  An android device and works quite well.  Samsung's site is also up-front on their use of cookies!  The browser has an ad blocker.  I can't modify the HOST file as I have not rooted the device.
  2. Dell Inspiron 15 7000 Series.  A high end laptop with Windows 10.  Even here I have to use a HOST file and ad blockers as some sites are so bloated they take up to 30 seconds to render.
Now I can hear web sites saying we need the ad revenue to stay in business.  Some have even gone as far as to run scripts to scan for ad blockers and then block their site until we turn off our blockers.  For those companies who actively block me when I run ad blockers I just go elsewhere and a good site gets my 'business' and you get absolutely $0.00 in ads from my visit.
  1. When you use third party ad companies to present ads on your behalf you are trusting them to ensure their sites show us legit ads.  Well check out the links here and here for malware issues.  Why should I open up my machine to malware served by YOU?  You can claim that it is the ad company, but, you picked them, you trusted them, you are taking their money for presenting those ads and in my not so humble opinion the buck stops at your desk!
  2. Your advertising partners are doing their best to track everything I read and where I go in order to 'serve' me more 'relevant' ads.  Relevant in whose opinion?  When I read an article on diabetes does not mean I want to get flooded with targeted ads on blood meters and related items.
  3. I do unblock the good sites.  I understand their need to make money and the ads they serve are good and don't hog my bandwidth or system.  They also respect my privacy and try their best not to track my behavior.
The latest beef I have about ad blockers is that some of them are now white-listing sites and taking the choice out of my hands for what sites can present me ads.  Well that cost them a loyal user as I dropped them from EVERY browser in EVERY device in my house.  When it comes to ads and sites I am the final arbiter and no one else!

For users I have a few things for you to think about.
  1. If you are technically inclined check out using a HOST file.  You can then pick the more annoying sites to block. 
  2. Virus scanner software.  There are a lot of good ones and many are fairly inexpensive.  Personally I use AVAST as it is cross platform (Windows, Mac and Android), inexpensive, doesn't hog system resources and it just works.  
  3. An up-to-date Browser.  This is important and the latest versions have bug fixes to minimize exploits.
  4. Ad blocking software that allows you to white-list sites.  You can then tailor your blocking and allow sites that respects you to be able to serve ads and allow them to stay in business.  For me I like UBlock origin and Flashblock.  They work in Windows, Android and Linux for my Firefox browser.

An example white-list from UBlock origin (hmmm, seems like there is only one site there, probably because I don't want to advertise who I white-list).
White-list options, Slashdot is one of the GOOD sites I allow ads.  I hid the others.

Thursday, March 17, 2016

Netbook is now Linux

The run with Win10 on the netbook is over.  It was fine, but, I get nervous seeing how many pieces of the system call home for stuff I can't control or turn off.  That and I want to be in control on what gets upgraded and not have it forced on me.  I have been using Linux for years on a variety of machines and it was easy to convert this machine.

The conversion took only an hour and I was up-and-running.  The distro I am using is LUBUNTU and it is quite light on the machine.  I had to make a few changes.  The default word processor and spreadsheet were replaced with LibreOffice.  I prefer it as my Windows laptop runs it and it is easier to work with when I have only one app to keep up-to-date.  Same with GIMP for both machines.  I did remove light-locker and replace it with xscreensaver.  For the system monitor I put on GKRELLM.  To make things work I had to modify the startup via LXSession configuration.  One other quirk was that the touchpad would always start every time I log in and not respect my settings.  That was easy to fix on the start in LXSession.  To do screen captures I had to install Gnome Screenshot as the screen shot key doesn't seem to work.  All of the software is in the Synaptic Package Manager.

Modify startup for my preferences

The best part is it takes about one minute to start up the machine and about 10 seconds to do a complete shutdown.  Windows startup was around 2 minutes and at least a minute for shutdown.

Current screen looks like the image below.

My main screen setup
 Once I got the basics set up I then launched the software updater facility.  It downloaded everything, installed, cleaned up, rebooted and I got the latest version of LUBUNTU.

The only package so far I couldn't find was the driver for my Brother print/scanner.  Upside is that Brother does support Linux and I could download and install the files.  Once there I configured my printer without too much effort.  I had to use the IP address, but, once filled in the printer worked without issue.  The next thing I have to check out is the scanner option.  I also have an Epson Scanner that I want to see if it works on the machine too.  Windows 10 would not support it and I was thinking of buying a new scanner, but, if the netbook recognizes it I can save money by not purchasing a new scanner.

Brother printer/scanner recognized




Saturday, March 12, 2016

Has customer service died, or, are businesses that arrogant?

 Sigh, companies are doing less and less for consumers and charging more for what little they keep in stock.  They must think that with limited (in their eyes) competition we have to take what they offer and be grateful for that.
  • Tried to buy a scanner, no scanner, but, we do carry muti-function printers with a scanner.  I told them I didn't want a MFP, I wanted a scanner and they pointed me to a competitor up the road!  Smart move Best Buy!
  • Tried to buy a replacement drive for a laptop. No we don't carry those, but, we do have inexpensive laptops if you are interested.  They also mentioned the same computer shop up the street from where I live where I could buy a replacement drive. Way to go The-Source!
  • Next up, I tried to buy replacement batteries for my wife's watches. "No we can't open up the back and replace the batteries" according to the sales person.  Another win for The-Source!

The-Source used to be Radio Shack until they got bought out by another company. I loved Radio Shack as they carried a great selection of materials and they knew their stuff and were willing to help.  The-Source is carrying less and less items that would be of use to me and the prices tend to be higher than ALL of the competitors. To rephrase what their web page has at the top "They don't have that" or "You can't have that".

This weekend capped off a perfect several weeks where I wanted to purchase an item.  I wanted to get my wife a simple Android phone from Virgin Mobile.  Pay for the phone up front and go pay-as-you-go.  The first place we went to was Best Buy and for five minutes we were ignored by the sales staff, I guess they had more important personal business to do rather than make a sale.  We went across the street to the mall and The-Source.  I was approached by a sales person quickly (yay) and I told him what I wanted.  He told me "They can't do that".  Excuse me?  Last year we got two Virgin Mobile phones, paid up-front and went pay-as-you-go at that same store.

It looks like I will be stopping in at the Virgin Mobile store in the downtown mall and buy a phone there and go pay-as-you-go and Best Buy and The-Source will get $0.00 for their effort and Virgin Mobile gets all of the money.  I like Virgin Mobile as they give good value for the money, very helpful when I call with a question/issue and know what customer service is!

Update 2016/03/15:

I stopped in at the Virgin Mobile store yesterday at lunch in the Rideau Centre here in Ottawa.  As soon as I walked in I was greeted and asked if there was anything he could do.  I explained I was looking for an Android phone on a pay-as-you-go plan.  No problem, he asked any specific model or price range.  I replied max $250.  He had the model in the range and allowed me to check it out.  I liked what I saw and the specs so I told him it was a sale.  A few minutes at the checkout, buying a bit of time so the wife had a few minutes call time to start with.  From the time I entered, paperwork and leaving it was max 20 minutes.  I liked the service and the attitude "How can we help you" and "We can do that".

I brought the phone home and my wife LOVES the phone.  It fits in her right hand easily and is very easy for her to use.  That is very important as she had a stroke and has problems using her left hand.  She was able to phone home and my cell phone without any problems and launched Google calendar for one of her appointments!  This is all that I wanted to get for her and two businesses lost an easy sale!

Thank you Virgin Mobile for making a simple task simple!

Tuesday, March 01, 2016

Windows 10 & Drivers - What a pain

Last week I wanted to use my scanner to make a copy of my various medical receipts.  The Epson Perfection 1650 worked well in Windows 7, minor tweaks in 8.1.  In Windows 10 it doesn't work at all.  It sees the scanner, but, does not recognize the driver.  This is a major annoyance as this is a fairly recent scanner.  I checked Epson and they don't support it.  The options are to move it to the laptop with Linux (wife's machine so I have to wait until she isn't using it) or buy a new scanner.

I checked a number of stores and most don't stock stand-alone scanners as they prefer multi-function machines.  I understand their reason as they get return business for replacement ink cartridges.  The problem is that I have 2 printers.  One is a color ink-jet and the other is a laser so I don't need a third printer.

Why do manufacturers abandon hardware when a new O/S comes out?  i know it costs a bit of money, but, if you design the driver properly it should be moderately easy to port.  If not why don't they open up the specs so hobbiests have an easier time of writing drivers?