Page 2 of 3

Posted: Thu 09 Dec 2010, 22:53
by jemimah
I got the mount point names working. Unfortunately a symlink to /media is not good enough. The drive must actually be mounted there. :(

EDIT: Moving everything to /media doesn't seem to really cause any problems. I wonder if there's any gotchas I'm not thinking of.

Posted: Sat 11 Dec 2010, 23:16
by abushcrafter
jemimah wrote:I got the mount point names working. Unfortunately a symlink to /media is not good enough. The drive must actually be mounted there. :(
What about hard links?
jemimah wrote:EDIT: Moving everything to /media doesn't seem to really cause any problems. I wonder if there's any gotchas I'm not thinking of.
A lot of scripts need to be updated.

Posted: Sat 11 Dec 2010, 23:24
by disciple
Might be easier to patch GTK to use /mnt instead of /media ;)

Posted: Sun 12 Dec 2010, 00:12
by jemimah
abushcrafter wrote:
jemimah wrote:I got the mount point names working. Unfortunately a symlink to /media is not good enough. The drive must actually be mounted there. :(
What about hard links?
jemimah wrote:EDIT: Moving everything to /media doesn't seem to really cause any problems. I wonder if there's any gotchas I'm not thinking of.
A lot of scripts need to be updated.
It won't let you hard link directories. (Plus I think it actually runs something like "mount |grep "/media".) As far as I can tell, only two scripts need to be patched, drive_all, and pmount. /mnt/home stays where it is.

Disciple's probably right though, a gtk patch is a more elegant solution.

Posted: Sun 12 Dec 2010, 03:18
by jemimah
Great! I now have a working patch for libgio that fixes this.

Posted: Sun 12 Dec 2010, 19:36
by abushcrafter
jemimah wrote:Great! I now have a working patch for libgio that fixes this.
Great 8).

With the drive labels for the desktop drive icons. I find I need more padding between the icons because I have longer labels than you two do. Examples: "goodcontent" and "alexanderspuppyl".

Posted: Sun 12 Dec 2010, 21:22
by jemimah
Yup I've fixed that too.

Posted: Mon 13 Dec 2010, 12:22
by abushcrafter
So why does the syslink "/mnt/home" work then?

Looking forward to you sharing your goodies :wink:. I hope they could be squeezed into the next/current Lupu, LHP and Wary releases.

Suggestion on drive icons with volume label

Posted: Wed 02 Feb 2011, 09:19
by Sit Heel Speak
Thank you very much akash_rawal and upnorth and jemimah, this is really useful!

Suggestion --if anyone is skilled enough and cares:

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". This will enable placement of the drive icon as close to the edge as possible, which allows a little bit bigger windows without totally eclipsing the drive icons.

Also it would allow perfect alignment even in the case when some (or in my case, most) of the drive partitions do not have volume labels.

I must say...the screencap is of Puppy Studio 3.3's icewm, on a 20" monitor at 1600x1200, with the positions of the icewm taskbar and wbar swapped...drive icons told to line up "left" in
/etc/eventmanager...gkrellm added...this Puppy Studio 3.3 version of icewm (icewm-1.3.7pre2-L519-lucid) is the best window manager I have ever seen in Puppy. Windows open in logical places and usually at reasonable sizes. It is even better than openbox and enlightenment e17. And that's saying something.

If it were possible to set margins in icewm, like you can in openbox, it is hard to imagine how it could be better. Well, maybe if it had the same right-click-on-titlebar, remember-position-and-size that e17 has. But even without an explicit remember function it does much better than jwm, openbox, e17 and earlier versions of icewm as far as opening new windows in logical places.

Posted: Wed 02 Feb 2011, 11:38
by nooby
Looks very helpful this one.

Don't get angry now but when one do search using google then labels and Label can get mixed very easily :)

labels being what can be read under the icon on a desktop
Label being the UUID that is a random? long unintelligent uuid 7ak5.... human not easily remembered line of chars.

Desktop label
Harddisk label

Posted: Tue 29 Mar 2011, 10:45
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.
_____________________________________________________________________________

Posted: Sun 03 Apr 2011, 18:09
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

Posted: Mon 04 Apr 2011, 10:07
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?

Posted: Thu 07 Apr 2011, 11:15
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!

Posted: Fri 15 Apr 2011, 17:41
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.

Stuck at slving second problem

Posted: Sat 23 Apr 2011, 07:59
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.

Posted: Sat 23 Apr 2011, 10:50
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?

Posted: Sat 23 Apr 2011, 12:15
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.

Posted: Sat 23 Apr 2011, 13:09
by nooby
Akash if you look on grub4dosconfig that Shinobar has a thread about does not that one list every OS that is installed?

Posted: Sun 24 Apr 2011, 09:54
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.