Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Thu 30 Oct 2014, 13:09
All times are UTC - 4
 Forum index » Taking the Puppy out for a walk » Suggestions
Some suggestions that will make Puppy excellent
Moderators: Flash, Ian, JohnMurga
Post_new_topic   Reply_to_topic View_previous_topic :: View_next_topic
Page 3 of 4 Posts_count   Goto page: Previous 1, 2, 3, 4 Next
Author Message
akash_rawal

Joined: 25 Aug 2010
Posts: 232
Location: ISM Dhanbad, Jharkhand, India

PostPosted: Tue 29 Mar 2011, 06:45    Post_subject:  

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:

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:

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:

# 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-

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.
_____________________________________________________________________________

Edited_time_total
Back to top
View user's profile Send_private_message 
akash_rawal

Joined: 25 Aug 2010
Posts: 232
Location: ISM Dhanbad, Jharkhand, India

PostPosted: Sun 03 Apr 2011, 14:09    Post_subject:    

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:

#!/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:

Edited_time_total
Back to top
View user's profile Send_private_message 
abushcrafter


Joined: 30 Oct 2009
Posts: 1447
Location: England

PostPosted: Mon 04 Apr 2011, 06:07    Post_subject:  

Thanks akash_rawal Very Happy.

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?

_________________
adobe flash is rubbish!
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/
Back to top
View user's profile Send_private_message Visit_website 
akash_rawal

Joined: 25 Aug 2010
Posts: 232
Location: ISM Dhanbad, Jharkhand, India

PostPosted: Thu 07 Apr 2011, 07:15    Post_subject:  

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!
Back to top
View user's profile Send_private_message 
akash_rawal

Joined: 25 Aug 2010
Posts: 232
Location: ISM Dhanbad, Jharkhand, India

PostPosted: Fri 15 Apr 2011, 13:41    Post_subject:  

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.
Back to top
View user's profile Send_private_message 
akash_rawal

Joined: 25 Aug 2010
Posts: 232
Location: ISM Dhanbad, Jharkhand, India

PostPosted: Sat 23 Apr 2011, 03:59    Post_subject: Stuck at slving second problem  

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.
Back to top
View user's profile Send_private_message 
akash_rawal

Joined: 25 Aug 2010
Posts: 232
Location: ISM Dhanbad, Jharkhand, India

PostPosted: Sat 23 Apr 2011, 06:50    Post_subject:    

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

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?
Back to top
View user's profile Send_private_message 
Flash
Official Dog Handler


Joined: 04 May 2005
Posts: 11125
Location: Arizona USA

PostPosted: Sat 23 Apr 2011, 08:15    Post_subject:  

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.
Back to top
View user's profile Send_private_message 
nooby

Joined: 29 Jun 2008
Posts: 10557
Location: SwedenEurope

PostPosted: Sat 23 Apr 2011, 09:09    Post_subject:  

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
Back to top
View user's profile Send_private_message 
akash_rawal

Joined: 25 Aug 2010
Posts: 232
Location: ISM Dhanbad, Jharkhand, India

PostPosted: Sun 24 Apr 2011, 05:54    Post_subject:  

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:

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.
Back to top
View user's profile Send_private_message 
akash_rawal

Joined: 25 Aug 2010
Posts: 232
Location: ISM Dhanbad, Jharkhand, India

PostPosted: Mon 25 Apr 2011, 10:23    Post_subject:    

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:

# 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.
Back to top
View user's profile Send_private_message 
akash_rawal

Joined: 25 Aug 2010
Posts: 232
Location: ISM Dhanbad, Jharkhand, India

PostPosted: Thu 19 May 2011, 08:42    Post_subject: Done  

I have written the program successfully.
It is here: http://www.murga-linux.com/puppy/viewtopic.php?p=524405#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.
Back to top
View user's profile Send_private_message 
akash_rawal

Joined: 25 Aug 2010
Posts: 232
Location: ISM Dhanbad, Jharkhand, India

PostPosted: Thu 09 Jun 2011, 09:35    Post_subject: 4. Shutting down puppy by power button  

4. Shutting down puppy by power button

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

#!/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.
Back to top
View user's profile Send_private_message 
SimpleWater

Joined: 19 Apr 2011
Posts: 95

PostPosted: Fri 10 Jun 2011, 22:45    Post_subject:  

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?
Back to top
View user's profile Send_private_message 
akash_rawal

Joined: 25 Aug 2010
Posts: 232
Location: ISM Dhanbad, Jharkhand, India

PostPosted: Sat 11 Jun 2011, 02:24    Post_subject:  

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 Embarassed I was too busy in maintaining Boot Loader Manager.

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

acpitool -s

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

#!/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:

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?
Back to top
View user's profile Send_private_message 
Display_posts:   Sort by:   
Page 3 of 4 Posts_count   Goto page: Previous 1, 2, 3, 4 Next
Post_new_topic   Reply_to_topic View_previous_topic :: View_next_topic
 Forum index » Taking the Puppy out for a walk » Suggestions
Jump to:  

Rules_post_cannot
Rules_reply_cannot
Rules_edit_cannot
Rules_delete_cannot
Rules_vote_cannot
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.1313s ][ Queries: 13 (0.0098s) ][ GZIP on ]