Customizable default applications

New features which should be implemented in Porteus; suggestions are welcome. All questions or problems with testing releases (alpha, beta, or rc) should go in their relevant thread here, rather than the Bug Reports section.
Post Reply
maverick
White ninja
White ninja
Posts: 15
Joined: 29 Nov 2011, 16:08
Location: The Great North

Customizable default applications

Post#1 by maverick » 29 Nov 2011, 16:45

Hey guys,

This is more of a feature request than a module request but what I would love to see is an easier way to customize default applications, at least the web browser, text editor and terminal. The way this could be done is by setting up symlinks called "default-browser", "default-texteditor" and "default-terminal" to which KDE and LXDE would point in the system menu and whenever files of the relevant type are opened. Then we can easily create modules which would replace the default modules for Porteus and allow users to customize the operating system how they want. For example, my favorite browser is Chromium and my favorite graphical text editor is gedit. I would love to be able to delete the Firefox xzm and a leafpad/Kate xzm and simply create a Chromium xzm and a gedit xzm which include the appropriate symlinks and get a desktop that looks like it was designed with my defaults in mind from the ground up, no more, no less. I believe this is how Puppy Linux does it.

Thanks and keep up the good work!

User avatar
Hamza
Warlord
Warlord
Posts: 1847
Joined: 28 Dec 2010, 07:41
Distribution: Porteus
Location: France

Re: Customizable default applications

Post#2 by Hamza » 29 Nov 2011, 16:52

Is there is a feature for this in brokenman's module tools?

Posted after 1 minute 32 seconds:
Thanks Ahau to have moved the topic!
NjVFQzY2Rg==

User avatar
Ahau
King of Docs
King of Docs
Posts: 1331
Joined: 28 Dec 2010, 15:18
Distribution: LXDE & Xfce 32/64-bit
Location: USA

Re: Customizable default applications

Post#3 by Ahau » 29 Nov 2011, 17:00

Welcome, maverick!

I've moved this thread to the "Development" section because it is a feature request (as you stated). I'll let the maintainers speak to whether or not and how this should be implemented.
Please take a look at our online documentation, here. Suggestions are welcome!

maverick
White ninja
White ninja
Posts: 15
Joined: 29 Nov 2011, 16:08
Location: The Great North

Re: Customizable default applications

Post#4 by maverick » 29 Nov 2011, 17:02

Sounds good to me, I would love to see this feature so let me know if I can be of any assistance :)

User avatar
fanthom
Site Admin
Site Admin
Posts: 4613
Joined: 28 Dec 2010, 02:42
Distribution: Porteus Kiosk
Location: Poland, currently - Cork, IE
Contact:

Re: Customizable default applications

Post#5 by fanthom » 29 Nov 2011, 20:12

@maverick
i think we have similar idea implemented already.
please have a look on /opt/porteus-scripts/paths script which creates symlinks for terminal, browser and file manager in /tmp folder duing GUI startup.
these sylinks are used by /usr/share/applications/*.desktop fiels for displaying FAQ (/tmp/.browser), launching various srcipts (/tmp/.terminal) and opening home folder (/tmp/wmanager - not sure why brokenman named it as wmanager :) ).

is it what were you looking for? any idea what could be added/improved?
Please add [Solved] to your thread title if the solution was found.

maverick
White ninja
White ninja
Posts: 15
Joined: 29 Nov 2011, 16:08
Location: The Great North

Re: Customizable default applications

Post#6 by maverick » 30 Nov 2011, 05:00

@fanthom,
thanks for the info, this is more or less what i had in mind but unfortunately i couldn't get it to work. i modified the /opt/porteus-scripts/paths script to prioritize chrome over firefox, deleted /tmp/.browser and restarted my computer. after this, firefox is still the only browser that shows up in my menu shortcuts bar and double clicking a .html file still opens firefox not chrome. to verify that my changes were persistent i did a "ls -l /tmp/.browser" and it did indeed point to chrome. what am i doing wrong?
assuming this did work, is it possible to modify parts of the paths file through an xzm module (as opposed to replacing it)? my vision is that each user is able to customize porteus as easily as deleting a module and adding another one. for example, in this case, there would be a chromium module which, once installed (and the firefox module disabled), makes sure that chromium integrates tightly with the system by showing up in the shortcuts bar and being used to handle all links and html files. the same goes for the default terminal, window manager and text editor.

User avatar
fanthom
Site Admin
Site Admin
Posts: 4613
Joined: 28 Dec 2010, 02:42
Distribution: Porteus Kiosk
Location: Poland, currently - Cork, IE
Contact:

Re: Customizable default applications

Post#7 by fanthom » 30 Nov 2011, 08:22

i modified the /opt/porteus-scripts/paths script to prioritize chrome over firefox, deleted /tmp/.browser and restarted my computer. after this, firefox is still the only browser that shows up in my menu shortcuts bar and double clicking a .html file still opens firefox not chrome.
file associations are fixed by 'update-desktop-database' utility which is called during activation of a module. this was not the case for Porteus-1.0 and LXDE so if you are using these please run 'update-desktop-database' as root manually.
in Porteus-1.1 all should work just fine.
Please add [Solved] to your thread title if the solution was found.

User avatar
brokenman
Site Admin
Site Admin
Posts: 5542
Joined: 27 Dec 2010, 03:50
Distribution: Porteus v3.2rcX all desktops
Location: Brazil
Contact:

Re: Customizable default applications

Post#8 by brokenman » 30 Nov 2011, 13:55

I think your problem here lies with file association.
You want your chosen browser to open by default when you click a html file right?

I will answer from a 32bit KDE 3.5.12 perspective and you can work it out in KDE4 if that's what your using.
Kmenu/Settings/Kde Components/File Association
Now type html into the filter and rearrange (or add) your preferred browser to the top of the list.
------
For getting your menu items to appear in the menubar ... that is something that must be done during creation of the module, or afterwards using the panel editors. The symlink system we have in /tmp/.shorcuts will only be useful for anyone creating an application or custom module, and they point the executer to the symlink. For example i want my script to open the documents folder ... i use /tmp/.wmanager $HOME/documents

In this way a script will work from both LXDE & KDE & XFCE. You could also add the Exec=/tmp/.browser line to a desktop file of a module to have it launch the default application.
------
To have gedit open by default when you lick on text files, or have browserX open when you click on html ... you are really talking about mimetypes and file associations, so the symlink idea is subpar to the already existing system in place for this. Every operating system uses this paradigm so no need to reinvent the wheel here. Correct me if i misunderstood you please.

PS: .wmanager = windowmanager (late nights,no sleep ) it should be .fmanager = filemanager

(insert emoticon for slapping oneself with a wet fish)
How do i become super user?
Wear your underpants on the outside and put on a cape.

User avatar
Ahau
King of Docs
King of Docs
Posts: 1331
Joined: 28 Dec 2010, 15:18
Distribution: LXDE & Xfce 32/64-bit
Location: USA

Re: Customizable default applications

Post#9 by Ahau » 05 Dec 2011, 19:59

I have an idea in mind for this...maverick, please let me know if this sounds like it would do what you want.

I would write a script that would find all of the desktop items in /usr/share/applications, and display them for the user to see. The user would select applications from the list that they would like to hide from the panel and mimetype selection. The script would generate a module containing a script that would run at startup and relocate the selected desktop entries out of /usr/share/applications. Thus, they would not show up in the panel or be selected as defaults for the various mimetypes. Being a module, it would work in saved changes mode and always fresh.

Thoughts? Does this do what you're looking for?

Posted after 2 days 2 hours 11 minutes 54 seconds:
Here's an early draft script. Right now it only works for the .desktop items in /usr/share/applications, and not those in subdirectories (e.g. kde). It has the user edit a config file in mcedit; if this concept went forward I would want this to be done through Xdialog.

Warning: Only those who like running with scissors should use my draft scripts. I'd suggest running it in always fresh mode only. It will create a module that you need to move to /porteus/modules.

To use: copy the text below into an empty text file. run chmod +x on it to make it executable, then run it as root.

Code: Select all

#! /bin/bash
#script to hide desktop items from the menu and mimetype database

if [ `whoami` != root ]; then
  echo you must be root to use this script. Exiting now.
  exit
fi


tmpdir=/tmp/pdhide/
tmpsh=$tmpdir/etc/rc.d/init.d/pdhide.sh
tmpconf=$tmpdir/etc/pdhide.conf

if [ -e $tmpdir ]; then
  rm -r $tmpdir
fi

mkdir -p $tmpdir/etc/rc.d/init.d/
mkdir $tmpdir/etc/rc.d/rcS.d
mkdir $tmpdir/etc/rc.d/rc4.d

if [ -e /etc/pdhide.conf ]; then
  cp /etc/pdhide.conf $tmpdir/etc/
  else
  touch $tmpdir/etc/pdhide.conf
fi

for i in `ls /usr/share/applications | grep .desktop`;
 do
  dname=`echo $i | cut -d '.' -f1`
  if ! grep -q $dname $tmpconf; then
    echo "$dname=false" >> $tmpconf
  fi ;
done

touch $tmpsh

echo '#! /bin/bash' >> $tmpsh
echo '' >> $tmpsh
echo 'if [ "$1" = "start" ]; then' >> $tmpsh
echo '' >> $tmpsh
echo '  if [ ! -d /usr/share/pdhide/ ]; then' >> $tmpsh
echo '    mkdir /usr/share/pdhide/' >> $tmpsh
echo '  fi' >> $tmpsh
echo '' >> $tmpsh
echo '  for i in `cat /etc/pdhide.conf | grep -i true`;' >> $tmpsh
echo '  do' >> $tmpsh
echo '    aname=`echo $i | cut -d '=' -f1`' >> $tmpsh
echo '    dname=$aname.desktop' >> $tmpsh
echo '    if [ -e /usr/share/applications/$dname ]; then' >> $tmpsh
echo '      mv /usr/share/applications/$dname /usr/share/pdhide/' >> $tmpsh
echo '    fi ;' >> $tmpsh
echo '  done' >> $tmpsh
echo 'fi' >> $tmpsh
echo '' >> $tmpsh
echo 'if [ "$1" = "stop" ]; then' >> $tmpsh
echo '  cd /usr/share/pdhide' >> $tmpsh
echo '  mv * ../applications/' >> $tmpsh
echo 'fi' >> $tmpsh

chmod +x $tmpsh
###

cd $tmpdir/etc/rc.d/rcS.d/
ln -s ../init.d/pdhide.sh S-pdhide
cd $tmpdir/etc/rc.d/rc4.d/
ln -s ../init.d/pdhide.sh K-pdhide

cd $tmpdir/etc
echo "about to open pdhide.conf in mcedit. change false to true for any applications you wish to hide, then press F10 to save, and then esc twice to exit. Press any key to continue."
read garbage
mcedit $tmpconf

dir2xzm $tmpdir ~/Desktop/pdhide.xzm

echo "module created as ~/Desktop/pdhide.xzm.  Copy this to your /porteus/modules/ folder and restart."
exit 
Please take a look at our online documentation, here. Suggestions are welcome!

maverick
White ninja
White ninja
Posts: 15
Joined: 29 Nov 2011, 16:08
Location: The Great North

Re: Customizable default applications

Post#10 by maverick » 08 Dec 2011, 18:28

Thanks for the help everyone!

Sorry for the delayed response, it's been a tremendously busy week.
brokenman I agree that it is a file association problem and I know how to change file associations manually but I was hoping for a solution that would work in always fresh mode and that would enable me and other novice users to "feel at home" in Porteus easily within a few seconds of downloading or installing it.

Ahau you're definitely on the right track, now only if this could be included in the Porteus Settings Centre! My only (minor) issues with your solution are:
1- It didn't work for me. mozilla-firefox.desktop and leafpad are both still part of my /usr/share/applications folder. pdhide.sh does show up in init.d but I imagine it's not running. Could it be because I'm running Porteus 1.0?
2- If I understand how this works correctly, it would keep firefox on the system increasing the disk space used on my USB disk while completely hiding it from the menu, not just preventing it from being the default. That's OK for me but I would rather that it remains on the menu (but not the "quick launch" panel at the bottom) without being the default, or simply completely uninstall it as easily as replacing a Firefox xzm with a customized Porteus Chromium xzm. I understand that this can't be done for every application though so your solution is probably the best we can do.

User avatar
Ahau
King of Docs
King of Docs
Posts: 1331
Joined: 28 Dec 2010, 15:18
Distribution: LXDE & Xfce 32/64-bit
Location: USA

Re: Customizable default applications

Post#11 by Ahau » 08 Dec 2011, 19:35

Yes, maverick, you're correct -- that approach would not erase it from the system, just hide it from the menu and update-desktop-database. You can easily drop the firefox module and add something else (note-- you'd have to add flash support separately as well), but you're also right about the panel launchers.

I just put something together for my XFCE module (see here: http://porteus.org/forum/viewtopic.php?f=75&t=854) that blends what you're asking for here with the /opt/porteus-scripts/paths concept. I've created a panel launcher with a non-application-specific icon (i.e., generic browser icon), and it's launch command is a script that launches firefox if it's present, and launches midori if firefox is not present. This could probably be implemented by a script in a module that would edit the kde configuration. It would start to get tricky, though, because different users will want a different priority for their applications. This approach also would not address the concern over what application took precedence for opening filetypes -- that would still have to be set through KDE/lxde, as described by brokenman above.
Please take a look at our online documentation, here. Suggestions are welcome!

User avatar
wread
Module Guard
Module Guard
Posts: 1090
Joined: 09 Jan 2011, 18:48
Distribution: Porteus v3.2.5-kde5-64 bits
Location: Santo Domingo
Contact:

Re: Customizable default applications

Post#12 by wread » 11 Dec 2011, 03:38

@maverick
You login Always Fresh, set your preferences as brokenman told you and then make a "mychanges.xzm" module, put it in "modules" and you will have porteus customized your way everytime it starts.... :) Elemental, Watson!

Welcome an board!
Porteus is proud of the FASTEST KDE ever made.....(take akonadi, nepomuk and soprano out and you will have a decent OS).
The Porteus Community never sleeps!

maverick
White ninja
White ninja
Posts: 15
Joined: 29 Nov 2011, 16:08
Location: The Great North

[Solved] Re: Customizable default applications

Post#13 by maverick » 09 Jan 2012, 14:31

Thanks everyone,
While not what I originally had in mind, all of you proposed good solutions and workarounds. I didn't know about the mychanges.xzm feature, it's been very useful lately.
Thanks again

Post Reply