Some suggestions that will make Puppy excellent

What features/apps/bugfixes needed in a future Puppy
Message
Author
akash_rawal
Posts: 229
Joined: Wed 25 Aug 2010, 15:38
Location: ISM Dhanbad, Jharkhand, India

#31 Post by akash_rawal »

A few more suggestions added, see the first post.
__________________________________________________________________________

I recently learnt usage of "cut" command and using it I made a better script to show drive labels.
Add these functions to /sbin/pup_event_frontend_d:

Code: Select all

blkid_cleaner() {
	sleep 5
	if [ -f /tmp/blkid.txt ]; then rm /tmp/blkid.txt; fi
}

blkid_name_generator() {
	#Gather blkid output and filter out required device
	if [ ! -f /tmp/blkid.txt ]; then
		blkid -c /dev/null > /tmp/blkid.txt
	fi
	blkid_cleaner &
	LABEL=""
	eval $( cat /tmp/blkid.txt | grep "$@:" | cut --delimiter=" " -f 2- | sed -e 's/ /;/g' )
	LABEL=${LABEL//;/ }
	#Generate drive label
	if [ "$LABEL" = "" ]; then ONEDRVLABEL="$@\n \n "; else ONEDRVLABEL="${LABEL}\n($@)\n "; fi
}
Then edit the functions named add_pinboard_func and remove_pinboard_func as follows-

Code: Select all

add_pinboard_func() { #needs ONEDRVNAME, DRV_CATEGORY, FSTYPE
 #ppPATTERN=' label="'"$ONEDRVNAME"'"'
 #v411 rerwin: avoid icon getting duplicated if it is renamed...
 ppPATTERN="/root/.pup_event/drive_${ONEDRVNAME}<"
 [ "`grep "$ppPATTERN" /root/Choices/ROX-Filer/PuppyPin`" != "" ] && return #precaution.
 free_coord
 blkid_name_generator $ONEDRVNAME
 echo -e "<?xml version="1.0"?>
<env:Envelope xmlns:env="http://www.w3.org/2001/12/soap-envelope">
 <env:Body xmlns="http://rox.sourceforge.net/SOAP/ROX-Filer">
  <PinboardAdd>
   <Path>/root/.pup_event/drive_${ONEDRVNAME}</Path>
   <X>${COORD_X}</X>
   <Y>${COORD_Y}</Y>
   <Label>${ONEDRVLABEL}</Label>
   <Args>${DRV_CATEGORY} ${FSTYPE}</Args>
  </PinboardAdd>
 </env:Body>
</env:Envelope>"  | rox -R
if [ "$( cat /root/.drvlist | grep $ONEDRVNAME )" = "" ]; then
echo $ONEDRVNAME >> /root/.drvlist
fi
}

remove_pinboard_func() { #needs DRV_NAME (name of entire drive)
 #ppPATTERN=' label="'"$DRV_NAME"'.*" '
 #[ "`grep "$ppPATTERN" /root/Choices/ROX-Filer/PuppyPin`" = "" ] && return
 #ALLNAMES="`grep -o "$ppPATTERN" /root/Choices/ROX-Filer/PuppyPin | cut -f 2 -d '"' | tr '\n' ' '`" #'geany
 #for ONEDRVNAME in $ALLNAMES
 #do
  #echo "<?xml version="1.0"?>
#<env:Envelope xmlns:env="http://www.w3.org/2001/12/soap-envelope">
 #<env:Body xmlns="http://rox.sourceforge.net/SOAP/ROX-Filer">
  #<PinboardRemove>
   #<Path>/root/.pup_event/drive_${ONEDRVNAME}</Path>
  #</PinboardRemove>
 #</env:Body>
#</env:Envelope>"  | rox -R
 #done
 #Rewritten to cope with blkid_name_generator
 cat /root/.drvlist | grep "$DRV_NAME" |
 while read ONEDRVNAME
 do
 echo "<?xml version="1.0"?>
<env:Envelope xmlns:env="http://www.w3.org/2001/12/soap-envelope">
 <env:Body xmlns="http://rox.sourceforge.net/SOAP/ROX-Filer">
  <PinboardRemove>
   <Path>/root/.pup_event/drive_${ONEDRVNAME}</Path>
  </PinboardRemove>
 </env:Body>
</env:Envelope>"  | rox -R
 sed -i -e "s/${ONEDRVNAME}//g" /root/.drvlist
 done
}

This one is a bit faster ( and I also think that the option "-c /dev/null" corrects the problem of incorrect output when another somewhat similarly partitioned hard disk is connected ).
One additional newline at end of each label ensures that the original margin is restored.
_____________________________________________________________________________
jemimah wrote: Plus I think it actually runs something like "mount |grep "/media"
I don't think GTK file dialog runs 'mount | grep "/media" '. I concluded this by the following experiment on Puppy 412.
I extracted the pup_412.sfs file into a directory. Then I renamed /mnt to /media, created symlink /mnt pointing to /media and recombined it into an sfs.
When I got puppy to boot using the sfs file thus formed, I got very unexpected results. I mounted a few drives and then opened GTK file dialog, but no drives were listed there (except root and File System). When I ran 'mount | grep "/media" ' in terminal I got:

Code: Select all

# mount | grep "/media"
/dev/sda5 on /media/sda5 type fuseblk (rw,user_id=0,group_id=0,blksize=4096)
/dev/sda6 on /media/sda6 type fuseblk (rw,user_id=0,group_id=0,blksize=4096)
# 
_____________________________________________________________________________
abushcrafter wrote: I find I need more padding between the icons because I have longer labels than you two do.
Sit Heel Speak wrote: When the drive icons are arranged vertically, as in this screencap, the justification of the labels (both volume label and partition drive+number) should not be "center" but rather should match the orientation of the icons, e.g. "right", "left".
...
If it were possible to set margins in icewm, like you can in openbox, it is hard to imagine how it could be better.
I searched a lot but couldn't find any option for changing text alignment in ROX-Filer
I think that icons could be better placed in a panel instead of on pinboard as follows-
Image
This will have several advantages:
1. Users will have choice of aligning icons against any side of the screen.(However at the bottom the panel will be partially covered by the taskbar, rendering it useless)
2. ROX-Filer will automatically manage panel width and icon spacing to accommodate longer labels.
3. Panels can be configured not to allow maximized windows to cover them, so window managers like openbox is not needed for that purpose.
_____________________________________________________________________________
Last edited by akash_rawal on Tue 12 Apr 2011, 06:57, edited 1 time in total.

akash_rawal
Posts: 229
Joined: Wed 25 Aug 2010, 15:38
Location: ISM Dhanbad, Jharkhand, India

#32 Post by akash_rawal »

I found a way to show mounted drives in GTK File Dialog, by modifying /root/.gtk-bookmarks file.
Just copy the following in a text file in /root/Startup:

Code: Select all

#!/bin/sh

function blkid_name_generator() {
	#Copied from pup_event_frontend_d and edited: blkid_name_generator(), Finds drive labels
	#Gather blkid output and filter out required device
	LABEL=""
	eval $( blkid | grep "$@:" | cut --delimiter=" " -f 2- | sed -e 's/ /;/g' )
	LABEL=${LABEL//;/ }
	#Generate drive label
	if [ "$LABEL" = "" ]; then ONEDRVLABEL="$1"; else ONEDRVLABEL="${LABEL}($1)"; fi
	ONEDRVDISP=${ONEDRVLABEL// /%20}
}
function mksymlink() {
	#Create symlinks to mountpoints in /mnt
	mkdir -p /media
	ln -T -s -f "$DIR" "/media/$ONEDRVLABEL"
}
function getdata() {
	#Gets data from mount command
	mount | grep "/dev/" | grep "/mnt/" | cut -d " " -f 1-3 |
	while read DRIVEU W DIR ; do
		DRIVE=${DRIVEU##*/}
		blkid_name_generator "$DRIVE"
		echo -n "file:///media/$ONEDRVDISP\n"
		mksymlink "$DIR"
	done
}
function chkdata() {
	#Cutdown of getdata just for checking for changes
	mount | grep "/dev/" | grep "/mnt/"
}

NEWCDATA=""
while [ 1 = 1 ]; do
	OLDCDATA="$NEWCDATA"
	NEWCDATA="$( chkdata )"
	if [ "$OLDCDATA" != "$NEWCDATA" ]; then
		NEWDATA="$( getdata )"
		#Filter out old entries
		echo -n > /tmp/gtk-bookmarks
		cat /root/.gtk-bookmarks |
		while read LINE; do
			case "$LINE" in
			file:///media/*/*)
				[ "$LINE" != "" ] && echo "$LINE" >> /tmp/gtk-bookmarks
			;;
			file:///media/*)
			;;
			*)
				[ "$LINE" != "" ] && echo "$LINE" >> /tmp/gtk-bookmarks
			;;
			esac
		done
		#Add new entries
		echo -ne "$NEWDATA" > /root/.gtk-bookmarks
		cat /tmp/gtk-bookmarks >> /root/.gtk-bookmarks
		echo "updated"
	fi
	sleep 1
done
		
Then restart X or execute it.
After that mounted drives will appear in the side pane, with their labels.
Only problem is that the drive will be given a folder-like icon, so users can misinterpret it as a bookmark.
Screenshot:
Image
Last edited by akash_rawal on Tue 12 Apr 2011, 07:01, edited 1 time in total.

User avatar
abushcrafter
Posts: 1418
Joined: Fri 30 Oct 2009, 16:57
Location: England
Contact:

#33 Post by abushcrafter »

Thanks akash_rawal :D.

I call the script that shows mounted drives in GTK File Dialog, by modifying /root/.gtk-bookmarks file "showmounteddrivesingtkfiledialogworkaround". So can we all agree on this or a name then?
[url=http://www.adobe.com/flashplatform/]adobe flash is rubbish![/url]
My Quote:"Humans are stupid, though some are clever but stupid." http://www.dependent.de/media/audio/mp3/System_Syn_Heres_to_You.zip http://www.systemsyn.com/

akash_rawal
Posts: 229
Joined: Wed 25 Aug 2010, 15:38
Location: ISM Dhanbad, Jharkhand, India

#34 Post by akash_rawal »

abushcrafter wrote:I call the script that shows mounted drives in GTK File Dialog, by modifying /root/.gtk-bookmarks file "showmounteddrivesingtkfiledialogworkaround".
That will be complete name of the script.
Consider having underscores between terms, like "show_mounted_drives_in_gtk_file_dialog_workaround".

However I hardly bother to give long names. I had just named the file "show_mounted_drives" and finished the story!

akash_rawal
Posts: 229
Joined: Wed 25 Aug 2010, 15:38
Location: ISM Dhanbad, Jharkhand, India

#35 Post by akash_rawal »

It is strange that no one moved the discussion to next topic i.e. automatically detecting different OSes installed on the computer and generating correct config to boot them using grub.

I have performed many experiments on virtualbox with many different setups of hard disks and controllers and found that grub-install command gets confused with many of the setups.(I haven't tested grub bootloader config yet) I am now almost sure how grub detects various drives.

Now all I have to search is a program or a library that can give detailed information about all the controllers and drives attached to them. Till now I haven't found it.

Next challenge is to detect different OSes installed in the computer and generating correct config. This is easy for windows, just checking the presence of windows bootloader files is enough. For linux, apart from detecting location of kernel and initrd, correct options have to be found out. Detecting puppy linux is most difficult. Puppy can have kernel and initrd in one drive and its sfs and save files in another drive.

akash_rawal
Posts: 229
Joined: Wed 25 Aug 2010, 15:38
Location: ISM Dhanbad, Jharkhand, India

Stuck at slving second problem

#36 Post by akash_rawal »

I have started writing a bootloader config program which could autodetect OSes. But I am stuck at a problem. How could my program detect which OS is installed in a particular drive?

I have already written code which could detect presence of Linux in a particular drive and generate configuration that should work for many Linux. But I don't know how to find which Linux is that. The same applies to Windows.Puppy Linux excluded, I have already written an almost foolproof code that can detect presence of Puppy Linux and generate correct config, even if the SFS files are in other partition.

I have seen Ubuntu and Linux Mint installers automatically detecting all windows and many Linux distros correctly. I wonder how they do that. On searching with Google I get unwanted results.

Development of my program has reached the point from where I cannot continue without solving the problem. Please help.

akash_rawal
Posts: 229
Joined: Wed 25 Aug 2010, 15:38
Location: ISM Dhanbad, Jharkhand, India

#37 Post by akash_rawal »

I accidentally found this web page:
http://www.doxer.org/learn-linux/linux- ... an-ostype/
I found that reading /etc/issue gives the name of the entire OS. /etc/issue file in my Linux Mint installation reads:

Code: Select all

Linux Mint 8 Helena - Main Edition \n \l
I easily get the name of the Linux ready to be displayed in boot menu.
I think this will work for many popular Linux (Please check whether I am correct). For other Linux my program can at least show "Unknown Linux (on <drive_name>)" and generate config that should work for most Linux I think.

Now I just have to find ways to fight off the problem of autodetecting windows. Am I missing out any other OS?

User avatar
Flash
Official Dog Handler
Posts: 13071
Joined: Wed 04 May 2005, 16:04
Location: Arizona USA

#38 Post by Flash »

Is what's in /etc/DISTRO_SPECS or /initrd/DISTRO_SPECS what you're looking for? I don't know if those are in every distro, or even every version of Puppy.

nooby
Posts: 10369
Joined: Sun 29 Jun 2008, 19:05
Location: SwedenEurope

#39 Post by nooby »

Akash if you look on grub4dosconfig that Shinobar has a thread about does not that one list every OS that is installed?
I use Google Search on Puppy Forum
not an ideal solution though

akash_rawal
Posts: 229
Joined: Wed 25 Aug 2010, 15:38
Location: ISM Dhanbad, Jharkhand, India

#40 Post by akash_rawal »

Flash wrote:Is what's in /etc/DISTRO_SPECS or /initrd/DISTRO_SPECS what you're looking for? I don't know if those are in every distro, or even every version of Puppy.
I am using exactly same method to detect Puppy Linux. Extract initrd.gz, then execute DISTRO_SPECS (for earlier versions, read PUPPYVERSION which contains 3-digit puppy version number). This gives the name as well as the version. Then pick the kernel present in the same directory (and hope for the best) and go. This method works perfectly even if SFS files are in other partition.
nooby wrote: Akash if you look on grub4dosconfig that Shinobar has a thread about does not that one list every OS that is installed?
I got hold of grub4dos-0.4.4.v1.7.pet and extracted it and found that the mechanism to detect Windows was very simple:

Code: Select all

case $KEYFILE in
  /bootmgr)  DISTRO_NAME="Windows Vista/2008/7" ;;
  /ntldr) DISTRO_NAME="Windows NT/2000/2003/Xp"
    [ -f $TOPDIR/boot.ini ] && DISTRO_NAME=$(grep 'WINDOWS=' $TOPDIR/boot.ini| head -n 1| cut -d'=' -f2| cut -d'/' -f1|  tr -d '"' | trim)
    [ "$DISTRO_NAME" = "" ] && DISTRO_NAME="Windows NT/2000/2003/Xp"
    ;;
  /io.sys) DISTRO_NAME="Windows 9x/Me";;
esac
It can detect that Windows Vista/2008/7 is installed in a drive, but can't distinguish between Windows Vista, 2008 and 7. Linux Mint and Ubuntu installers are able to do that.

akash_rawal
Posts: 229
Joined: Wed 25 Aug 2010, 15:38
Location: ISM Dhanbad, Jharkhand, India

#41 Post by akash_rawal »

I got a nice way to differentiate between Windows Vista and 7.
After searching a lot I found the source code of os-prober-1.44 and in it found an easy way to read /Boot/BCD binary file to determine Windows OSes booting from it.
In file os-probes/mounted/x86/20microsoft:

Code: Select all

# Vista (previously Longhorn)
if item_in_dir -q bootmgr "$2" && boot="$(item_in_dir boot "$2")" &&
   bcd="$(item_in_dir bcd "$2/$boot")"; then
	if grep -qs "W.i.n.d.o.w.s. .7" "$2/$boot/$bcd"; then
		long="Windows 7 (loader)"
	elif grep -qs "W.i.n.d.o.w.s. .V.i.s.t.a" "$2/$boot/$bcd"; then
		long="Windows Vista (loader)"
	elif grep -qs "W.i.n.d.o.w.s. .S.e.r.v.e.r. .2.0.0.8. .R.2." "$2/$boot/$bcd"; then
		long="Windows Server 2008 R2 (loader)"
	elif grep -qs "W.i.n.d.o.w.s. .S.e.r.v.e.r. .2.0.0.8." "$2/$boot/$bcd"; then
		long="Windows Server 2008 (loader)"
	elif grep -qs "W.i.n.d.o.w.s. .R.e.c.o.v.e.r.y. .E.n.v.i.r.o.n.m.e.n.t" "$2/$boot/$bcd"; then
		long="Windows Recovery Environment (loader)"
	elif grep -qs "W.i.n.d.o.w.s. .S.e.t.u.p" "$2/$boot/$bcd"; then
		long="Windows Recovery Environment (loader)"
	else
		long="Windows Vista (loader)"
	fi
	short=Windows
# 2000/XP/NT4.0
elif ...
There is one mistake though, "grep -qs" should be replaced by "grep -ao".
Now just wait for a week or two, my program will be out.

akash_rawal
Posts: 229
Joined: Wed 25 Aug 2010, 15:38
Location: ISM Dhanbad, Jharkhand, India

Done

#42 Post by akash_rawal »

I have written the program successfully.
It is here: http://www.murga-linux.com/puppy/viewto ... 405#524405
Please check whether detection of MSDOS/Win95/98/ME works properly. I cannot do it becauseI don't have one. I have an old windows 98SE setup disk but VirtualBox cannot boot it.

akash_rawal
Posts: 229
Joined: Wed 25 Aug 2010, 15:38
Location: ISM Dhanbad, Jharkhand, India

4. Shutting down puppy by power button

#43 Post by akash_rawal »

4. Shutting down puppy by power button

This one is pretty easy.
Just wrote a small shell script of just 5 lines:

Code: Select all

#!/bin/sh
cat /proc/acpi/event |
while read line; do
	wmpoweroff
done
You may want to replace "wmpoweroff" with your favorite shutdown manager like PupShutdown.

SimpleWater
Posts: 94
Joined: Tue 19 Apr 2011, 11:53

#44 Post by SimpleWater »

I have one, how about a hibernate, standby, sleep or whatever you call it mode. I use that in windows all the time, to save energy you know?

akash_rawal
Posts: 229
Joined: Wed 25 Aug 2010, 15:38
Location: ISM Dhanbad, Jharkhand, India

#45 Post by akash_rawal »

SimpleWater wrote: I have one, how about a hibernate, standby, sleep or whatever you call it mode. I use that in windows all the time, to save energy you know?
Sorry I forgot :oops: I was too busy in maintaining Boot Loader Manager.

There is acpitool which can put your computer to standby using a simple command:

Code: Select all

acpitool -s
However this doesn't work directly for my desktop, so I wrote a wrapper script:
/usr/bin/acpitool:

Code: Select all

#!/bin/sh
if test -n "`echo "$@" | grep -i -- "-s"`"; then
	rmmod uhci_hcd
	rmmod ehci_hcd
	acpitool_ren $@
	modprobe uhci_hcd
	modprobe ehci_hcd
else
	acpitool_ren $@
fi

(assuming that you have renamed actual /usr/bin/acpitool to /usr/bin/acpitool_ren)

PupShutdown is a great shutdown manager which has option for both standby and hibernate but the GUI says:
Image
And when I try to hibernate it just says that hibernation support was not detected.
However standby option works properly
Anyone knows how to enable hibernation?

stu90

#46 Post by stu90 »

Hi akash_rawal,

What windows manager and theme are you running in that screen shot above?

i like! :D

akash_rawal
Posts: 229
Joined: Wed 25 Aug 2010, 15:38
Location: ISM Dhanbad, Jharkhand, India

#47 Post by akash_rawal »

stu90 wrote:Hi akash_rawal,

What windows manager and theme are you running in that screen shot above?

i like! :D
I am using:
  • Wallpaper: See the world.jpg
  • Window manager: Beryl, with Emerald decorator
  • Window decorator theme: A-New-Hope (see attachment)
  • Gtk theme: A-New-Hope (see attachment)
Attachments
gtk_theme_a_new_hope.pet
Requires murrine engine to work properly
(29.12 KiB) Downloaded 529 times

stu90

#48 Post by stu90 »

akash_rawal wrote:
stu90 wrote:Hi akash_rawal,

What windows manager and theme are you running in that screen shot above?

i like! :D
I am using:
  • Wallpaper: See the world.jpg
  • Window manager: Beryl, with Emerald decorator
  • Window decorator theme: A-New-Hope (see attachment)
  • Gtk theme: A-New-Hope (see attachment)
Thanks akash_rawal - i never herd of Beryl before - looks sweet. :)

cheers.

User avatar
recobayu
Posts: 387
Joined: Wed 15 Sep 2010, 22:48
Location: indonesia

Re: 4. Shutting down puppy by power button

#49 Post by recobayu »

thank you very much akash, now my luci 258 has label on drive icon.
how if the longer label cut to the wide of icon, for example "somethingdriveiconlabel" tobe "someth..."
maybe it is better.
:wink:
akash_rawal wrote:4. Shutting down puppy by power button

This one is pretty easy.
Just wrote a small shell script of just 5 lines:

Code: Select all

#!/bin/sh
cat /proc/acpi/event |
while read line; do
	wmpoweroff
done
You may want to replace "wmpoweroff" with your favorite shutdown manager like PupShutdown.


now i am really new and interested to studying programming with sh language on puppy.
i want to PupShutdown appear when i press powerbutton on my laptop.
Edit: i know how it be.
I use that script on /root/Startup. I restart x server, n i got it! My power button works.
thanks
:D

User avatar
pemasu
Posts: 5474
Joined: Wed 08 Jul 2009, 12:26
Location: Finland

#50 Post by pemasu »

Anyone knows how to enable hibernation?
Sorry about late response. I just now find this thread through posted link.

You enable hibernation when you compile the kernel with hibernation enabled.

Anyway, in Puppies hibernation is quite useless. It takes time to write the RAM content to the swap partition, after that it locks the swap partition, until you boot the same hibernated Puppy, and it takes time to write the swap content back.

Only useful usage I have found, is that you can install applications without savefile when using pristine, fresh frugal install. Hibernate the Puppy and you can that way shutdown your comp. When booting back to the same Puppy, you have those installed applications in hand without savefile created.

Puppy shuts down and starts many times faster than hibernation is able

Post Reply