Multi-Search3
Showing posts with label Live cd. Show all posts
Showing posts with label Live cd. Show all posts

Power Up Puppy Lucid510 Linux.Part2-US Holidays In System Prompt And Four More Tips!


Puppy Lucid510 Linux Desktop


In the last article, we discussed start menu customization and LHS taskbar tray customization. Let us continue with four more important tasks here - setting the System Prompt, Aliases, Rightclick-Open/With and Default Programs - four tasks that are useful to any Puppy Lucid510 Linux user at any time whether used at logon or after it.


1. SETTING THE SYSTEM PROMPT 
When useful? At logon or anytime 

Start a terminal [Startmenu-Utility-Urxvt terminal emulator].
See the pound sign[#]?
Now type
#export PS1=''
What happened? Pound's gone. Vanished. We are poor now, too bad, wait a second. Now type
ls
See the file list? Type
df
See the used, free space allocation display?

Hey, stop stop, where do you think are we going with this now?

Easy! Cool down! We just saw the effects of setting the system prompt to null a minute ago with
export PS1='' and got impoverished. Let us reset the system prompt with a better prompt. Type
export PS1="\h"
Got the hostname!
export PS1="\h-\u"
Hostname and the username!
export PS1="\h-\u-\w"
Hostname, username and the current working directory!
export PS1="\h-\u-\w-#"
At last! This code gave us the hostname, userid, current working directory and our pound back! We are rich again now! But why is everything in black and white? Let's add some color to it and also thank a reference site on the net for sharing a variant of the line of code below we are building upon.
export PS1="\[\033[07;35m\]\[\033[07;31m\]\h-\[\033[07;35m\]\u-\[\033[32;40m\]\w-\[\033[00;31m\]#\[\e[m\]"
Now, we can add our own string[HelloWorld] to display at the very beginning of the system prompt.
export PS1="\[\033[07;34m\]HelloWorld-\[\033[07;31m\]\h-\[\033[07;35m\]\u-\[\033[32;40m\]\w-\[\033[00;31m\]#\[\e[m\]"


While this is okay for this session, we need to do more to get it into the startup configuration file so it will run at every logon.

Steps to change the system prompt

Let's say this is the code for our system prompt.
export PS1="\[\033[07;34m\]HelloWorld-\[\033[07;31m\]\h-\[\033[07;35m\]\u-\[\033[32;40m\]\w-\[\033[00;31m\]#\[\e[m\]"

Changing the system prompt for all users

1.Open a terminal as the root user and type
#cd /etc
2.Type
#geany profile & [Now put the above code at the end of the file, save and exit]
3.Run the command below
#. profile

Changing the system prompt for individual users only

1.Open a terminal as the user and type
$cd [user's home dir]
2.Type
$geany .profile & [Now put the above code at the end of the file, save and exit]
3.Run the command below
$. .profile


Note: In general, in any system where the user logs on using the bash, bourne and korn shells, the .profile file in the user's home directory is run first. In my Puppy Lucid510 Linux system, as I am the ONLY user on my system, I used the /etc/profile file to put this code in there even though it is a system-wide file. On bigger systems with many users, the individual .profile files in each user's home directory must be used instead!


JWhat's Bonus - Display US Holidays In The System Prompt!


Here's a little code block I came up with that you can append to your startup file [user's .profile or system's /etc/profile] to display the month, date and major US holidays in the system prompt. Thanks to a little oneliner I found on a reference site or forum on the net, we also get to colorize the system prompt and to display the hostname, username, and current working directory too!

What? Holidays in system prompt? Who'd want that? Everyone'll be home anyway!

Yeah, but for those who mess with their Linux systems all the time, it may make sense. Again you can add birthdays, anniversaries and important days to make it really useful even on regular days!!!

Requirement
The holiday prompt is refreshed only when the .profile or /etc/profile is run which is at every login/relogin or bootup/reboot. So, remember to put this line of code in a script and run it first thing everyday with cron.

For individual users run this line from a cron-scheduled script everyday at 00:01am
. .profile

For all users run this line from a cron-scheduled script everyday at 00:01am
. /etc/profile

Anyway, here is the code block
#========================================================
#Display major US holidays and more in the system prompt 
#========================================================
dat=`date +"%e,%b"`
if [ "$dat" == " 1,Jan" ]; then 
export PS1="\[\033[07;34m\]$dat-NewYear'sDay-\[\033[07;31m\]\h-\[\033[07;35m\]\u-\[\033[32;40m\]\w\[\033[00;31m\]#\[\e[m\]"
elif [ "$dat" == " 6,Jan" ]; then 
export PS1="\[\033[07;34m\]$dat-Epiphany-\[\033[07;31m\]\h-\[\033[07;35m\]\u-\[\033[32;40m\]\w\[\033[00;31m\]#\[\e[m\]"
elif [ "$dat" == " 2,Feb" ]; then 
export PS1="\[\033[07;34m\]$dat-GroundHogDay-\[\033[07;31m\]\h-\[\033[07;35m\]\u-\[\033[32;40m\]\w\[\033[00;31m\]#\[\e[m\]"
elif [ "$dat" == "14,Feb" ]; then 
export PS1="\[\033[07;34m\]$dat-Valentine'sDay-\[\033[07;31m\]\h-\[\033[07;35m\]\u-\[\033[32;40m\]\w\[\033[00;31m\]#\[\e[m\]"
elif [ "$dat" == " 8,Mar" ]; then 
export PS1="\[\033[07;34m\]$dat-Women'sDay-\[\033[07;31m\]\h-\[\033[07;35m\]\u-\[\033[32;40m\]\w\[\033[00;31m\]#\[\e[m\]"
elif [ "$dat" == " 1,Apr" ]; then 
export PS1="\[\033[07;34m\]$dat-AprilFool'sDay-\[\033[07;31m\]\h-\[\033[07;35m\]\u-\[\033[32;40m\]\w\[\033[00;31m\]#\[\e[m\]"
elif [ "$dat" == "14,Jun" ]; then 
export PS1="\[\033[07;34m\]$dat-FlagDay-\[\033[07;31m\]\h-\[\033[07;35m\]\u-\[\033[32;40m\]\w\[\033[00;31m\]#\[\e[m\]"
elif [ "$dat" == " 4,Jul" ]; then 
export PS1="\[\033[07;34m\]$dat-4thOfJuly-IndependenceDay-\[\033[07;31m\]\h-\[\033[07;35m\]\u-\[\033[32;40m\]\w\[\033[00;31m\]#\[\e[m\]"
elif [ "$dat" == "31,Oct" ]; then 
export PS1="\[\033[07;34m\]$dat-Halloween-\[\033[07;31m\]\h-\[\033[07;35m\]\u-\[\033[32;40m\]\w\[\033[00;31m\]#\[\e[m\]"
elif [ "$dat" == "11,Nov" ]; then 
export PS1="\[\033[07;34m\]$dat-Veteran'sDay-\[\033[07;31m\]\h-\[\033[07;35m\]\u-\[\033[32;40m\]\w\[\033[00;31m\]#\[\e[m\]"
elif [ "$dat" == " 8,Dec" ]; then 
export PS1="\[\033[07;34m\]$dat-ImmaculateConceptionOfBVM-\[\033[07;31m\]\h-\[\033[07;35m\]\u-\[\033[32;40m\]\w\[\033[00;31m\]#\[\e[m\]"
elif [ "$dat" == "24,Dec" ]; then 
export PS1="\[\033[07;34m\]$dat-ChristmasEve-\[\033[07;31m\]\h-\[\033[07;35m\]\u-\[\033[32;40m\]\w\[\033[00;31m\]#\[\e[m\]"
elif [ "$dat" == "31,Dec" ]; then 
export PS1="\[\033[07;34m\]$dat-NewYear'sEve-\[\033[07;31m\]\h-\[\033[07;35m\]\u-\[\033[32;40m\]\w\[\033[00;31m\]#\[\e[m\]"
else 
export PS1="\[\033[07;34m\]$dat-HelloWorld!-\[\033[07;31m\]\h-\[\033[07;35m\]\u-\[\033[32;40m\]\w\[\033[00;31m\]#\[\e[m\]"
fi
#========================================================


Now, let's make sure that the code block above works correctly!

1.Open the /etc/profile file. Copy the code block above and paste it at the end. Save it.
2.Open a terminal.
3.Set the date to January 1.
Press [Start menu], then [Desktop] and then [Set date and time]. Use arrows by the left and right of the month to go to [January] and set the date to [1]. Press [Ok].
4.In the next window [Set time tool], press [Ok].
5.In the next window [info], press [Ok] and wait for a few seconds.
6.Now, in the terminal, type
# . /etc/profile

If everything's fine we should be seeing "1,Jan-NewYear'sDay..." in the system prompt.

Here's the fun part!
You can accomplish lots of different things other than displaying the dull boring [#] or [$] symbol in the system prompt by modifying the code block above. For example, you can
* Birth days/Anniversaries: 
 Add your own birth day or important family or friends' anniversaries etc.
 [Eg. 3,Mar-Musa'sBirthDay!-puppypc-root-~-#]
* Holidays: 
 Change the holiday list by adding, deleting or changing the holidays.
 [Eg. 1,Jan-NewYear'sDay!-puppypc-root-~-#]
* Reminders[Yoga]: 
 Set aside a week or two and practice one yoga pose per day! 
 It's really fun.[Mountain, Cat, Cow, DFDog, Sphinx...]
 [Eg. 3,Mar-MountainPose!-puppypc-root-~-#]
* Reminders[Todo]: 
 Display a todo item till it is completed.
 [Eg. 3,Mar-CompleteHomePageRedesign!-puppypc-root-~-#]
* Affirmations: 
 Use a one-word affirmation from the list below. Many of these come from 
 a squidoo lens here
 Believe.Smile.Relax.Easy.Think.Practice.Exercise.Learn.Amaze.Build.
 Create.Nurture.Hope.Live.Peace.Listen.Improve.Forgive.Encourage.Dare.Act.
 Excel.
 [Eg. 3,Mar-Smile!-puppypc-root-~-#]
* Favorite Text: 
 Add your name or your favorite person's name or any text at the beginning 
 of the prompt by changing the [HelloWorld!] in the last export statement 
 before the [fi] at the very end if you'd like to. The possibilities are endless.
 [Eg. 3,Mar-Believe!-puppypc-root-~-#]

That's it for the system prompt configuration, let us move to aliases.

2. SETTING COMMAND SHORTCUTS WITH ALIAS
When useful? At logon or anytime

Consider the Linux command "ls". Let us type the following at the system prompt.
#ls -lstrh
This command displays a time sorted, human-readable listing of files in the current directory with the latest files at the end. It would be great if instead of typing
ls -lstrh
every time everywhere we create a shortcut like
l
wouldn't it? We can then type
#l
at the command prompt easily every time! That's what we did in the first line of the alias command list above [See image above]. For a one-time run, we can create a session-expiring alias like this. [Note: My system also allowed me to use single quotes instead of double quotes!]
#alias l="ls -lstrh" 
If we want to be more enterprising, we can put this shortcut into a persistent file that is run by default at every login. In Puppy Lucid510, this persistent config file /root/.bashrc has only one line pointing to
#. /etc/profile
and /etc/profile in turn is used to store all default login configuration parameters. So, let us open the /etc/profile file and put these lines at the end of the file. Since /etc/profile is run every time the /root/.bashrc file is run, which is at every logon, we're all set! [Note: Bigger systems with many users must use the .profile file at the user's home directory instead] Let's test it out real quick. First open /etc/profile with geany text editor.
#geany /etc/profile & 
Let's type this line at the end of this file.
alias l="ls -lstrh"
Let's save this file and run /root/.bashrc for our changes to take effect immediately.
#. /root/.bashrc
Once we have done the above we can then simply type 'l' at the dollar prompt from a terminal in any directory to view a neat, time-sorted and human-readable listing!
#l
Did you see the listing as we expected? I did!


3. CREATING SOFTLINKS FOR THE ROX-FILER RIGHTCLICK OPENWITH/SENDTO 
When useful? At logon or anytime

It's easy to customize the way we want to open different file types with different programs of our choice in Puppy Lucid510. For example, assume we want to rightclick on a html file and open it with Chromium, Firefox or Opera. This is what we need to do.

ln -s /usr/bin/chromium-browser /root/.config/rox.sourceforge.net/SendTo/chrome 
ln -s /usr/bin/firefox /root/.config/rox.sourceforge.net/SendTo/firefox 
ln -s /usr/bin/opera /root/.config/rox.sourceforge.net/SendTo/opera 

We have just created three softlinks for these three programs at the 
[/root/.config/rox.sourceforge.net/SendTo] folder. Changes take place immediately
so we can rightclick on a html file and select [OpenWith] to make sure we can open it with any of the
three browsers mentioned above.

NOTE: The information below comes from the window that opens when we rightclick on a file or folder and choose [File] or [Dir] menu, then select [Openwith] and then select [Customize] at the bottom.

The [Send To] menu provides a quick way to send some files to an application. 
The applications listed are those in the following directories:

/root/.config/rox.sourceforge.net/SendTo
/etc/xdg/rox.sourceforge.net/SendTo

I'll show you your SendTo directory now; you should symlink (Ctrl+Shift drag) 
any applications you want into it. The 'Send To' menu may be opened by Shift+Menu clicking over a file.

Advanced use:
You can also create subdirectories called '.text_html', '.text', etc which will 
only be shown for files of that type. '.group' is shown only when multiple files 
are selected.


4. SETTING DEFAULT PROGRAMS FOR DIFFERENT FILE TYPES
When useful? At logon or anytime 

What, you are not satisfied with a [Rightclick-Open/With] strategy? We can also easily configure a program to open a filetype by default whenever we click on it. Just run these lines from the commandline or from within a script
#browser-chromium
echo '#!/bin/sh
exec chromium-browser "$@" '> /usr/local/bin/defaultbrowser
Now whenever we click on ANY html file it will be opened by Chromium. Just change it to Firefox or Opera if required.


5. BONUS TIP: INFINITE LOOP TO CHECK STATUS OF FILE COPY OR FILE DOWNLOAD

Whether we are copying a giant 1gb or bigger file locally, or downloading stuff over slow internet, there is an easy way to check progress from the commandline.
while true; do du /your-folder/your-giant-file ; sleep 20; date; done
First note the size of the source file before copying/download begins. Then run this command and see how it keeps updating the terminal with the latest file size every 20 seconds and so if the file size is the same several times, the download probably stopped with success or errors. We can press [Ctrl-C] to break out of the loop and check if the file has been downloaded successfully or copied fully and/or rerun the loop command if needed. The [date] command gives a timestamp to tie up the [file size] to. Change the [time interval] to repeat as needed.


Bye! Bye! Woof! Woof!

This completes part2 and also concludes the PowerUp Puppy Lucid510 Linux-Tips To Customize The Startup Sequence Series. There are tons of Linux distributions out there but we need to pick and choose the best one for our needs and requirements. Puppy Linux is a great choice especially if you want a Linux Live CD distribution in the 100-200 MB category that comes with a great working base image and also has a host of pets and other utilities to build up on.

That's really great, isn't it?

Last Updated: 11/3/2013.

Power Up Puppy Lucid 510 Linux - Two Tips To Customize The Start Up Sequence!


Puppy Start Menu - Add A New Menu Group
I have seen a bunch of Live CD Linux distros but when it comes to packing a ton of packages in a small size [Puppy Lucid 5.1.0-where I am still at-under 130MB; the latest Puppy Lucid 5.2.8 just 133MB, download from here], nothing comes close to Puppy Linux. Extendable for even more versatility and power with the dev package and with the ability to run from RAM without even a hard disk, we have most of what we need to run a decent family pc or laptop! Not forgetting the save files that help us keep our sanity by storing persistent settings across shutdowns, and the multitude of open source gems out there, there is hardly very little we'll miss unless we're sitting on the bleeding edge of computing. Let us consider two simple ways to pack even more punch to the Puppy startup sequence, first by customizing the Start Menu and secondly by customizing the LHS tray. Remember we are working with Puppy Lucid 510 Linux here. Don't squat somewhere in Arch Linux and complain if you find things missing or not as found here :)

I. CUSTOMIZING THE START MENU

Before
 

After Adding New Menu[JCMenu]

Before we start anything, let's backup the /root/.jwmrc file.

$cp /root/.jwmrc /root/.jwmrc.bkup

This is the file we need to change to customize the Start Menu. We can edit, delete or even add new entries to the Start Menu by changing the entries here. It creates the Puppy Start Menu [see "Before" image above on the left].

< ?xml version="1.0"? >
< JWM >
< !-- IMPORTANT, ONLY EDIT /etc/xdg/templates/_root_.jwmrc -- >
< !-- jwm menu for puppy Linux -- >
< RootMenu label="Menu" labeled="false" height="24" onroot="3" >

< Menu label="Desktop" icon="x24.png" height="16" >
< Menu label="Desktop Settings" icon="mini.window3d.xpm" height="16" >
< Program label="Chtheme GTK theme chooser" icon="mini.window3d.xpm" >gtk-chtheme< /Program >
< Program label="Configure Xlock screen locking" icon="mini-lock.xpm" >/usr/local/apps/Xlock/AppRun -configure< /Program >
...
< /Menu>
 < Separator/ > 
... 
...
< Menu label="Shutdown" icon="shutdown24.png" height="16" >
< !-- < exit confirm="false" icon="prompt16.xpm" label="Exit to prompt" > -->
< Program label="Exit to prompt" icon="prompt16.xpm" >exec wmexit< /Program >
< Program label="Reboot computer" icon="mini-turn.xpm" >exec wmreboot< /Program >
< Program label="Power-off computer" icon="mini-stop.xpm" >exec wmpoweroff< /Program >
< Program label="Restart X server" icon="mini-x.xpm" >restartwm< /Program >
< Restart label="Restart JWM" icon="mini-windows.xpm"/>
< !-- < Program label="Change Window Manager" icon="mini-windows.xpm" >changewm.sh< /Program > -->
< /Menu >
< /RootMenu >
< /JWM >
< /exit >

Let's just look at the menus and programs at the start of the file since this is where we need to insert code if we wanted to add a new menu or programs. We'll keep things simple and consider only how to add a simple new menu [JCMenu] with a few puppy programs and one of our own scripts between two existing menus [Fun] and [JWhatGKFJ-1], (see "Before" image above on the left). Remember that we can use the [< Separator/ >] tag to separate menus or menu items(programs themselves) just as we have used two separators in our [JCMenu] to separate three program groups (see "After" image above on the right). Assume that we have coded our stuff into the following block [Note:All tags below have been padded with the space character as the second character on the LHS and the RHS. These are for code display and need to be removed before use]:

< Menu label="JCMenu" icon="games24.png" height="16" >
< Program label="ConfigureTouchpad" icon="picpuz.png" >flsynclient &< /Program >
< Program label="PupApps" icon="picpuz.png" >PupApps &< /Program >
< Program label="PupControl" icon="picpuz.png" >PupControl &< /Program >
< Program label="SearchMonkey" icon="picpuz.png" >searchmonkey &< /Program >
< Separator/ >
< Program label="HTop" icon="picpuz.png" >rxvt -e /usr/bin/htop &< /Program >
< Separator/ >
< Program label="FreeSpace1" icon="picpuz.png" >/bin/echo "Free Space[df -h] ">/tmp/1.out; /bin/df -h>>/tmp/1.out; /bin/echo>>/tmp/1.out; /bin/echo "free ">>/tmp/1.out; /bin/free>>/tmp/1.out; geany /tmp/1.out; rm /tmp/1.out< /Program >
< /Menu >
< Separator/ >


Notice how we have used a menu label, a couple of image icons and a program group for our menu above.

MENU LABEL: The label is where we name our menu [JCMenu].

ICONS: For simplicity we are reusing existing Puppy icons games24.png from /usr/local/lib/X11/pixmaps for the menu and picpuz.png from /usr/share/pixmaps/ for the menu items.

PROGRAMS: Here are three ways we can run programs from the Start Menu.

1.For starting up most puppy default programs, we can just call them by name like this.
< Program label="PupApps" icon="picpuz.png" >PupApps &< /Program >

2.Programs such as htop that require the terminal for the whole duration of their run may need to be called like this.
< Program label="HTop" icon="picpuz.png" >rxvt -e /usr/bin/htop &< /Program >

3.Finally we may run our own one liners, shell scripts and we may even run more than one program and display the output at once. For example consider the last menu entry in our code above.
< Program label="FreeSpace1" icon="picpuz.png" >/bin/echo "Free Space[df -h] ">/tmp/1.out; /bin/df -h>>/tmp/1.out; /bin/echo>>/tmp/1.out; /bin/echo "free ">>/tmp/1.out; /bin/free>>/tmp/1.out; geany /tmp/1.out; rm /tmp/1.out< /Program >

The command sequence above runs two commands, collects the output and opens the output file with the Geany editor automatically showing us a nice human-readable free space view and also the free memory view seen below.

Free Space[df -h] 
Filesystem            Size  Used Avail Use% Mounted on
rootfs                727M  100M  628M  14% /
tmpfs                 727M  100M  628M  14% /initrd/pup_rw
tmpfs                 293M  292M  704K 100% /initrd/mnt/tmpfs
/dev/loop0            292M  292M     0 100% /initrd/pup_ro2
unionfs               727M  100M  628M  14% /
shmfs                 287M  140K  287M   1% /dev/shm
/dev/sda1             3.8G  3.3G  489M  88% /mnt/sda1
/dev/sdb1             1.9G  1.6G  305M  85% /mnt/sdb1

free 
              total         used         free       shared      buffers
  Mem:      1488768      1274172       214596            0       117244
 Swap:            0            0            0
Total:      1488768      1274172       214596

Okay, let's take our favorite menu code [shown in color red below] and plug it into the existing code just below the menu called [Fun]. Notice how nicely we have arranged four Puppy programs, htop after these, and our own command sequence menu item grouped neatly into nice blocks with seperators! After the code insert it looks like this.

< ?xml version="1.0"? >
< JWM >
< !-- IMPORTANT, ONLY EDIT /etc/xdg/templates/_root_.jwmrc -- >
< !-- jwm menu for puppy Linux -- >
< RootMenu label="Menu" labeled="false" height="24" onroot="3" >

< Menu label="Desktop" icon="x24.png" height="16" >
< Menu label="Desktop Settings" icon="mini.window3d.xpm" height="16" >
< Program label="Chtheme GTK theme chooser" icon="mini.window3d.xpm" >gtk-chtheme< /Program >
< Program label="Configure Xlock screen locking" icon="mini-lock.xpm" >/usr/local/apps/Xlock/AppRun -configure< /Program >
...
< /Menu >
 < Separator/ > 
... 
...
...
< Menu label="Fun" icon="games24.png" height="16" >
< Program label="PicPuz jigsaw puzzle" icon="picpuz.png" >picpuz< /Program >
< Program label="Rubix cube" icon="cube16.xpm" >rubix< /Program >
< Program label="Tile slider game" icon="mini-modules.xpm" >tile< /Program >
< Program label="XEmeraldia drop blocks" icon="xemeraldia.xpm" >xemeraldia< /Program >
< Program label="Xinvaders3d Arcade Game  " icon="xinvaders.png" >xinv3d< /Program >
< Program label="Xsoldier - space arcade" icon="xsoldier.xpm" >xsoldier< /Program >
< /Menu >
< Separator/ >

< Menu label="JCMenu" icon="games24.png" height="16" >
< Program label="ConfigureTouchpad" icon="picpuz.png" >flsynclient &< /Program >
< Program label="PupApps" icon="picpuz.png" >PupApps &< /Program >
< Program label="PupControl" icon="picpuz.png" >PupControl &< /Program >
< Program label="SearchMonkey" icon="picpuz.png" >searchmonkey &< /Program >
< Separator/ >
< Program label="HTop" icon="picpuz.png" >rxvt -e /usr/bin/htop &< /Program >
< Separator/ >
< Program label="FreeSpace1" icon="picpuz.png" >/bin/echo "Free Space[df -h] ">/tmp/1.out; /bin/df -h>>/tmp/1.out; /bin/echo>>/tmp/1.out; /bin/echo "free ">>/tmp/1.out; /bin/free>>/tmp/1.out; geany /tmp/1.out; rm /tmp/1.out< /Program >
< /Menu >
< Separator/ >
...
...
< Program label="Help" icon="help24.png" >exec defaulthtmlviewer file:///usr/share/doc/index.html< /Program >

< Menu label="Shutdown" icon="shutdown24.png" height="16" >

< Program label="Exit to prompt" icon="prompt16.xpm" >exec wmexit< /Program >
< Program label="Reboot computer" icon="mini-turn.xpm" >exec wmreboot< /Program >
< Program label="Power-off computer" icon="mini-stop.xpm" >exec wmpoweroff< /Program >
< Program label="Restart X server" icon="mini-x.xpm" >restartwm< /Program >
< Restart label="Restart JWM" icon="mini-windows.xpm"/ >
< !-- < Program label="Change Window Manager" icon="mini-windows.xpm">changewm.sh< /Program > -- >
< /Menu >
< /RootMenu >
< /JWM >

Remember to run the Restart JWM menu option from the Puppy Start Menu every time after any change is made to the /root/.jwmrc file to view changes. [Menu->Shutdown->Restart JWM].
Run Restart JWM After Changes
Once we do that we get to see the new menu [JCMenu] displayed as seen on the "Before" and "After" images above. That's our very own customized Start Menu, don't you love it? I do!



II. CUSTOMIZING THE LHS TRAY ON THE TASKBAR AT THE BOTTOM

Taskbar LHS Tray-Before
  
Taskbar LHS Tray-After Adding More Program Icons
   

Let's look at how we can improve the LHS tray next to the Start Menu icon on the taskbar at the bottom by adding some more icons there. As you know, this is probably the best place to keep icons of the top few programs we run everytime day after day. This time we'll modify the /root/.jwmrc-tray file to add more items to the LHS tray. As usual, let's backup the current file before we start.

$cp /root/.jwmrc-tray /root/.jwmrc-tray.bkup

This is what the code looks like initially:
< JWM > 
   < Tray  autohide="false" insert="right" x="0" y="-1" border="1" height="28" > 
      < !-- Additional TrayButton attribute: label -- > 
      < TrayButton label="Menu" icon="mini-dog.xpm" >root:3< /TrayButton > 
      < !-- < traybutton icon="gexec.xpm" popup="Run commandline" >exec:gexec< /TrayButton > -- > 
      < TrayButton popup="Show Desktop" icon="mini-desktop.xpm" >showdesktop< /TrayButton > 
      < TrayButton popup="Free space in drives" icon="mini-hdisk.xpm" >exec:partview< /TrayButton > 
      < TrayButton popup="Choose Default Browser" icon="www24.png" >exec:browser-default< /TrayButton > 
        
      < !-- Additional Pager attributes; width, height -- > 
      < Pager/ > 
      < !-- Additional TaskList attribute: maxwidth -- > 
      < TaskList/ > 
      < Dock/ > 
      < !-- Additional Swallow attribute: height -- > 
      < Swallow name="blinky" > 
  blinkydelayed -bg "#4D525B"
      < /Swallow > 
      < !--  -- > 
      < !--    asapmshell -u 4 -- > 
      < !--  -- > 
      < Swallow name="freememapplet" width="34" > 
        freememappletshell 
      < /Swallow > 
      < Swallow name="xload" width="32" > 
  xload -nolabel -fg red -hl white -bg "gray45"
      < /Swallow > 
      < Clock >minixcal< /Clock > 
   < /Tray > 
< /JWM >

This below is our code to add more programs to the LHS tray RIGHT next to the Start Menu icon:

        < TrayButton popup="Pupdial" icon="/usr/local/apps/Connect/.DirIcon" >exec:/usr/sbin/pupdial< /TrayButton > 
        < TrayButton popup="Term" icon="/usr/local/lib/X11/pixmaps/console48.png" >exec:/usr/bin/urxvt< /TrayButton > 
        < TrayButton popup="Rox" icon="/usr/local/lib/X11/pixmaps/home48.png" >exec:/usr/local/bin/rox< /TrayButton > 
        < TrayButton popup="Gny" icon="/usr/local/lib/X11/pixmaps/edit48.png" >exec:/usr/local/bin/defaulttexteditor< /TrayButton > 
        < TrayButton popup="Lck" icon="/usr/local/apps/Xlock/.DirIcon" >exec:/usr/bin/xlock< /TrayButton >
        < TrayButton popup="Save" icon="/usr/local/lib/X11/pixmaps/save48.png" >exec:/usr/sbin/save2flash< /TrayButton >
        < TrayButton popup="Htop" icon="/usr/local/lib/X11/pixmaps/draw48.png" >exec:/usr/bin/urxvt -e /usr/bin/htop< /TrayButton >

This is the final code with our inserted code in red. Remember to remove the spaces at start and end of every line, if copy/pasting:

< JWM > 
   < Tray  autohide="false" insert="right" x="0" y="-1" border="1" height="28" > 
      < !-- Additional TrayButton attribute: label -- > 
      < TrayButton label="Menu" icon="mini-dog.xpm" >root:3< /TrayButton > 
   < !-- exec:gexec< /TrayButton > --> 
      < TrayButton popup="Show Desktop" icon="mini-desktop.xpm" >showdesktop< /TrayButton > 
      < TrayButton popup="Free space in drives" icon="mini-hdisk.xpm" >exec:partview< /TrayButton > 
      < TrayButton popup="Choose Default Browser" icon="www24.png" >exec:browser-default< /TrayButton > 

  
        < TrayButton popup="Pupdial" icon="/usr/local/apps/Connect/.DirIcon" >exec:/usr/sbin/pupdial< /TrayButton > 
        < TrayButton popup="Term" icon="/usr/local/lib/X11/pixmaps/console48.png" >exec:/usr/bin/urxvt< /TrayButton > 
        < TrayButton popup="Rox" icon="/usr/local/lib/X11/pixmaps/home48.png" >exec:/usr/local/bin/rox< /TrayButton > 
        < TrayButton popup="Gny" icon="/usr/local/lib/X11/pixmaps/edit48.png" >exec:/usr/local/bin/defaulttexteditor< /TrayButton > 
        < TrayButton popup="Lck" icon="/usr/local/apps/Xlock/.DirIcon" >exec:/usr/bin/xlock< /TrayButton >
        < TrayButton popup="Save" icon="/usr/local/lib/X11/pixmaps/save48.png" >exec:/usr/sbin/save2flash< /TrayButton >
        < TrayButton popup="Htop" icon="/usr/local/lib/X11/pixmaps/draw48.png" >exec:/usr/bin/urxvt -e /usr/bin/htop< /TrayButton >    
        
        
      < !-- Additional Pager attributes; width, height -- > 
      < Pager/ > 
      < !-- Additional TaskList attribute: maxwidth -- > 
      < TaskList/ > 
      < Dock/ > 
      < !-- Additional Swallow attribute: height -- > 
      < Swallow name="blinky" > 
  blinkydelayed -bg "#4D525B"
      < /Swallow > 
      < !--  -- > 
      < !--    asapmshell -u 4 -- > 
      < !--  -- > 
      < Swallow name="freememapplet" width="34" > 
        freememappletshell 
      < /Swallow > 
      < Swallow name="xload" width="32" > 
  xload -nolabel -fg red -hl white -bg "gray45"
      < /Swallow > 
      < Clock >minixcal< /Clock > 
   < /Tray > 
< /JWM >
< /traybutton >

Remember to run the Restart JWM menu option from the Puppy Start Menu every time after any change is made to the /root/.jwmrc-tray file to view changes. [Menu->Shutdown->Restart JWM] and look what we got! A whole new bunch of icons added to the LHS tray! Hooray!

Taskbar LHS Tray-Before

Taskbar LHS Tray-After Adding More Program Icons


Look at the image above to see the before and after views of how the LHS tray looks at the bottom of the screen. This completes the first set of two power tips to enrich the start up sequence of Puppy Lucid 510 Linux. More to follow soon!

IMPORTANT INFORMATION!

A [space] character has been inserted after the first character and before the last character of some xml tags in the display code blocks to protect display and need to be removed before use if copy/pasted. For example,

 < Menu >
 < Separator/ > 
 < TaskList/ > 
 < Dock/ > 
from code display must have the spaces removed when used in xml source code.

UPDATE

Remember to use the bulk replace option in the text editor you use to save time and also to 
prevent some angry cursing. For example, in Geany and gnome-text-editor I used this method to 
remove the extraneous spacing in a few key strokes and a few seconds instead of individual 
replacements that might have taken for ever. Make changes first in a fresh new blank editor page so you can transfer the text to the script after the editing is complete. Where it applies 
below, remove the square brackets used for accent and to mark out the space character.

GEANY
   Type [geany] leaving out the square brackets from command line or start it from [Start Menu]->[Accessories]
   Paste and select the text to change.
   Press [Ctrl-H] to bring up the replace box and click on [Replace All] to expand. 
   Type [< ] in the [Search for] input box. 
   Type [<] in the [Replace with] input box.
   Press the [In Selection] button to complete.
   Similarly, repeat the same steps for [ >].

GNOME TEXT EDITOR
   Type [gnome-text-editor] leaving out the square brackets from command line or start it from [Start Menu]->[Programming] and paste the code.
   Press [Ctrl-H] to bring up the replace box.
   Type [< ] in the [Find what] input box. 
   Type [<] in the [Replace with] input box.
   Click on [Replace all at once] to select it.
   Type [Find and replace] to complete.
   Similarly, repeat the same steps for [ >].


Oneliner To Display Filesize With Line And Word Count




It looks logical but have you ever thought of the file size as the total number of characters in a file?

I didn't, for a very long time!

This command returns the size of all files in a directory with line, word and character counts also! As we said just above, the character count happens to be the filesize also!




wc `ls -p|grep -v "/$"`|gawk -F " " '{print $1 "\t" $2 "\t" $3 "\t" $4|"sort -gk 1"}'

Let us break it down:

wc : Find line, word and character counts

ls -p|grep -v "/$" : List files in directory without directory information

gawk -F " " '{print $1 "\t" $2 "\t" $3 "\t" $4 : List lines, words, chars and file
names

sort -gk 1 : Sort the above on line count


Just remember that

  • there should be no spaces in file names.
  • there should be at least one file in the directory.

Works on Puppy Lucid510 Linux, may work on other flavors. Test it out for yourself!


Rescue Your Trapped Cell Phone Image! Use An Upload Script!

Image Credit:it.wikipedia.org.
 
Problem

You once had a Windows(XP+) pc/laptop and used the Nokia PC Suite [Windows only] to manage transfer of your files, images, contacts etc between your cell phone and the outside world. And then your hard disk crashed and took the Nokia software with it. Until the disk repair/replacement and/or new pc/laptop purchase you decided to take the Linux route to digital survival. You miss a lot of your comfort programs, your tried-and-tested shortcuts and routines but you've learned to accept life, one live-cd startup/shutdown at a time. Thank goodness you have fairly decent, if not better, replacements for any and every Windows tool from open source  on your Linux pc, but there still are some sore points, the Nokia PC Suite, for example. It is Windows-only which means files and images on  your cell phone are literally locked out if you are on Linux! And when your pretty niece comes calling about the birthday photo you took on your cell phone a few months ago, you're stuck.

Solution
[*See Note Below]

Not to worry. There's  a way out! With a mobile browser like UCBrowser and an upload script like file-upload.php you can solve your problem easily!

Just make sure that you have access to a web hosting account with cpanel or similar tools.

Then download and install a file upload script from the internet [I used the file-upload.php (file upload form) script from zubrag.com]. There may be others like it if you can't use this for some reason.

Now change the parameters in the script to point to your server:
    1. destination folder
    2. max file size
    3. success url
If you don't use mysql database, you can comment out
  • the 4 db parameters
    1. db_host
    2. db_database
    3. db_username
    4. db_password
  • the table creation part
  • and the
  • The lines between
    # if (DO_LOG) {
    and # // if (DO_LOG)
Start your mobile browser [I used UCBrowser-an amazing, feature-filled mobile browser] and type www.yourservername.com/file-upload.php to bring up the file upload page with file name input.

First press the [Browse] button to select the image from the cell phone [E:\images\...\yourimage.jpg], and press the [Upload] button to upload it to your server.

That's all! Unless you have errors you should have your cell phone image now on your server from where you can download it to your pc/laptop or upload it to blogger, flicker etc.

In Short

Nokia Pc Suite is a Windows only software. While on Linux you can use a file upload script to transfer your images or files from your Nokia N73 or similar cell phone to your Linux pc/laptop or to other websites like blogger, flicker etc.

Note

Keep this route to file transfer as a last resort. The other 2 options might be easier if you can get them to work instead.

  1. Mass Storage Mode: Use Mass Storage Mode from                                     [Settings]Menu--->Tools--->Data Cbl
  2. Card Reader: Simply pull out the mini SD card and connect to it your pc/laptop from your card reader

File-upload.php Gets It Done


Real-Life Example

Proof of the pudding is in the eating. Here is how I used this method in a real-life situation. CLICK HERE to see an image of the century[12/12/12 12:12:12-image on the left] that was trapped and rescued using the approach described in this article!

Hit The Jackpot - With Xampp On Linux Puppy Lucid!


The 777 magic


Let us create a fresh new install of the Xampp environment on Linux Puppy Lucid 5.1 with the Apache web server running a MySQL database in the back end and also make a successful implementation of a Php sample application. This is a terrific way to create the environment from scratch and also start developing apps on the Linux platform with the Apache-Php-MySQL combo!




This Xampp install even has the webalizer tool to monitor the statistics of your local web server, really cool!


What jackpot? What has the title to do with this?

You see, when I first started this ambitious endeavor of building a web server on a pretty new [to me!] Puppy Lucid Linux environment, I thought I really had a monster of a task ahead, and it really did prove so, despite the fact that I already had a successful implementation of the Xampp on Windows XP before for my TpqcPhp Script Library app.  [By the way, if you wish to download a one-of-a-kind point-and-click real-time Oracle-Php Script Library Generator that lets you create a html script library from any of your (tuning) Oracle script directories on your drive, view the script and also run it at once with side-by-side links, try this now HERE. This tool helps you configure and use either Xampp or the regular LAMP stack for the web server on Windows XP]

Let us get back to our jackpot, What has the title to do with this?

Okay, so, even though Xampp makes such a small deal of this huge task on Windows or Linux, manually configuring it is not for the faint-of-heart.
And that's exactly why, after toiling for a while with a manual LAMPP stack, I
happened to get back to Xampp again, this time on the Puppy Lucid Linux platform.
And the only snag was the permission problem that wouldn't let MySQL start up properly but went away with the 777 magic and hence the title. Once you chmod 777 /tmp  and start Xampp, you've hit the jackpot! Looks like a known issue but thank the folks at various places on the net who offer this solution for this problem. Don't forget to verify your win with a look at
http://localhost/xampp/splash.php or just http://localhost.

I must mention something here. While the web server on Chrome[Chromium - chrome 6.0.428.0] did work successfully while connected to the internet, it wouldn't work when I went offline! I later found that this and earlier versions of Chrome have this behaviour but got fixed in later versions so for offline development work I had to find another browser, Opera worked perfectly.

Here is a puzzle for you, where has Opera kept a landmine hidden?

In the restart button of the download window. Absent-mindedly pressing the
Restart button when a 3-hour download on my speed-of-light dial up connection
was nearing completion reset it and made me start all over! Oh what pain!


Steps to install Xampp on Puppy Lucid Linux

1.Download Xampp for Linux
http://www.apachefriends.org/en/xampp-linux.html

2.Install Xampp with this command
tar xvfz xampp-linux-1.7.7.tar.gz -C /opt


3.Change the permissions on the /tmp folder
chmod 777 /tmp


4.Start Xampp
/opt/lampp/lampp start


5.Create passwords for the webroot folder, PhyMyAdmin, MySql root user and ftp user nobody. Keep the password same for simplicity.
/opt/lampp/lampp security

6.Configure /opt/lampp/etc/php.ini to disregard warning messages by commenting the following line
;ERROR_REPORTING = E_ALL | E_STRICT

7.Restart Xampp
/opt/lampp/lampp restart






8.Verify a successful Xampp install. You will have to login to your web server first with lampp/your-password  account you created in step 5.

http://localhost/xampp/splash.php or just http://localhost.


9.Install a sample Php application[code library from Roman Diaz]



This is an extremely useful and absolutely snappy app from http://www.romandiaz.me/codelib.
I really like this tiny but useful application with current techniques! Follow the instructions in the zip file or check out what I did to install this  code library on my laptop.


a.Create a new database[codelib] from PhpMyAdmin
   http://localhost/phpmyadmin
   Login as [root]. 
   Click [localhost] on RHS. 

   Click [Sql] from the topmenu on RHS. 
   Type [create database codelib;]    without the square brackets in the box and press the [GO] button.
    

b.Create user [codelib] with password [codelib] or your password and grant all
   privileges to this user
   Click [Reload navigation frame] icon at the end of row of icons on top of the LHS
   and select [codelib] database. 
   Click [Privileges] on RHS topmenu, click [Add new user]. 
   Under [Login Information] fill in the username[codelib],  hostname[localhost], 
   password[codelib]  and retype password. 
   Under [Database for user] select [
   Under [Global privileges] check all  and press [GO].

c.Download code library and unzip it to codelib folder
   http://www.romandiaz.me/codelib/download.php

d.Copy the codelib folder to webroot(/opt/lampp/htdocs). Usually you may get away
   with creating a soft link to the codelib folder from the webroot
   (ln -s /yourpath/codelib /opt/lampp/htdocs) but in the Puppy world you cannot
   use chmod command on files in your usb or even NT file systems! So you have to
   physically copy the whole folder to the webroot of the xampp install.
   cp -r /yourpath/codelib /opt/lampp/htdocs

e.Copy config_SAMPLE.php file to config.php and change dbname, dbuser,
   dbuserpwd, hostname in /opt/lampp/htdocs/codelib/config.php
   cd /opt/lampp/htdocs/codelib
   cp config_SAMPLE.php config.php 
   and change the dbname,dbuser,dbuserpwd and hostname in this file


e.Change permissions 
   chmod 777 install.php
   chmod 777 config.php


f.Run create.sql
  Click [codelib] on LHS.
  Click [import] on RHS. 
  Click [choose file] under [file to import]. 
  Select  /opt/lampp/htdocs/codelib/create.sql. 
  Click [go].
  Import should have run 17 queries.

g.Enter the following in your browser to get to the [create your account] screen.   
   http://localhost/codelib/install.php

h.Enter [codelib] for username and [codelib] for password to create account and press [submit].

i. Enter [codelib] for username and [codelib] for password and press [submit] to login to the code library! From now on you can go to
http://localhost/codelib
to login to your code library!

You don't have to gamble to hit the jackpot! Do it with Xampp on Puppy Lucid Linux!

Requirements

1.Pc or laptop with or without a hard disk(I'm running without a hard disk, I've been for a while. Life on a live-cd is unbearable now since I don't save the config on USB or cd which means it's like you reinstall your OS every day - nothing is remembered. But it should be normal once I start saving it.)
2.Puppy Lucid 5.1.0[Kernel 2.6.33.2]
3.Xampp for Linux 1.7.7 with
      a)Apache/2.2.21 (Unix) DAV/2 mod_ssl/2.2.21 OpenSSL/1.0.0c  PHP/5.3.8 mod_apreq2-20090110/
          2.7.1 mod_perl/2.0.5 Perl/v5.10.1
      b)Mysql Server version: 5.5.16
      c)MySQL client version: mysqlnd 5.0.8-dev
      d)PhpMyAdmin Version information: 3.4.5
      e)Php 5.3.8
4.Chrome Browser(6.0.428.0) works only with internet connection so use Opera(11.60) for offline development or get a newer version of chrome.


Disc Gone Crazy - Puppy To The Rescue!

Puppy Logo
[My first take on seeking redemption in puppy-land, but curb your canine queries. I'm not a goo.roo!]
With more than a decade of experience in IT and computers, I've had my share of adware, malware and virus-related agony and pain. I've camped at the safe boot for weeks-on-end recovering from unrelenting BSDs. And I have tried one solution after another to get things going.
Regardless of what my suffering was, my hard disks were always quietly gentle, even to the point of OEM restores. This is the first time my laptop died with a whirring, squeaky and noisy hard disk. Everything seemed be nice and calm, there were no warning signs but suddenly a month ago it crashed one night.
Anyway past is past, what do I do?
I now had a dead laptop and a live Nokia n73 cellphone with Internet but no way to get online from my laptop.
Well yes, my n73 did help me download loads of ISO's of live cds, some good, some dud. I could  burn cds and boot up to a mini-xp shell and also to an excellent tiny Linux distro, but in both cases, my n73 wouldn't let me dial the Internet through the phone modem to get the Internet connectivity which I desperately need for my digital survival. The windows live cd I tried, which is probably the only one of its kind, with its absolutely indispensable recovery tools just won't run the Nokia PC Suite so I could go online. The Linux live cd,  a tiny little Linux powerhouse had everything I needed except Internet connectivity. I wrestled with PPP, PPPOE and Wvdial day after vexing day, night after desperate night, downloading ISOs on my cellphone, burning cds and attempting to boot and connect  but always failing.
Anyway, after hundreds of hours and my patience nearing its limits, I found the Puppy route to laptop revival. What an awesome puppy!
I burned the Puppy Wary 5.3 ISO,  started the boot process not completely devoid of a lurking cynicism and couldn't believe my eyes when the screen came alive and carried the boot process through to completion, just seven clicks from start to the two "woof"s. I saw the welcome screen, the connect button on top-right, followed instructions mechanically and was online within a minute or two!
YES, it's true!
The amazing pupdial probed and discovered my modem, configured it, dialled and dropped me on the www like clockwork. My relief was so huge because my earlier attempts to configure ppp and wvdial were so pointless. I only had to enter the phone number of my dial up connection and the access point to get connected, so unbelievable!
This puppy, Wary 5.3 is the name, is a true hero, it's like a miracle to me.
So, is your hard disk dead, can't boot up and get online?
Take the puppy Linux route to online survival. Download and try Puppy Wary 5.3.
But be warned, it worked for me, your mileage may "WARY"!


BlogCollage


Blog Collage - Top Random Posts In No Particular Order

Mouseover the images for title and comments