View previous topic :: View next topic |
Author |
Message |
itsr0y Tux's lil' helper
Joined: 22 Dec 2002 Posts: 81
|
Posted: Mon Dec 22, 2003 6:40 pm Post subject: Automatic File-extension / Mime-type launcher |
|
|
One of the reasons I use Windows and not Linux is because Windows is more integrated. In Windows, I set up which program is my video player once, and every program uses that video player (mostly). In Linux, though, I have to set up each program to use a specific program for a specific function. That is, in, let's say, my newsreader, I have to tell it which program is my web browser, my media player, my video player, my pdf viewer, my printer, etc. I know that KDE and GNOME programs act like Windows (somewhat), but still, I have to set up both KDE and GNOME, and I still have to set up non-KDE, non-GNOME programs. This is a major pain in the ass.
What would be nice is to have one program that you send info to and it launches the right program automatically. For an early version, you could even use a shell script to do it. Pass in two parameters, a full file path and (optionally) a MIME-type (maybe), for example:
Code: | # autorun /home/itsr0y/movies/Matrix.mpg |
The program looks up in a file, say /etc/autorun, the MIME-type that you passed in (or file extension if you didn't put MIME-type) and launches the configured program. This way, all programs can be set to just run one program and you can configure everything in one spot. If you get a new video player, for example, you only have to change it one spot. Plus, if you do it this way, when you emerge a program, it can automatically add itself to the /etc/autorun file so users don't have to configure anything.
Another feature that can be added to this program (although probably not in the shell script versions) is to have multiple programs run one type. A window can pop up asking the user which program he wants to run, and a checkbox to make one program the default. This way, if he wants to change it, he can look in the /etc/autorun and just change the entry listed as "default".
For example, the /etc/autorun could look something like this:
Code: | .mpg /bin/mplayer
.avi /bin/mplayer
.wmv /bin/mplayer
.mp3 /bin/xmms
# The following two would prompt for which program to use with a .txt file
.txt /bin/gvim
.txt /bin/xemacs
# The following two would not prompt and only launch Firebird
.html /bin/MozillaFirebird default
.html /bin/mozilla |
I'm sure there would be better formats for the /etc file, but this is just starting idea.
Well, I hope you guys get the idea. This wouldn't be the only way to do what I want - you could have a daemon running, or you could simply have each program do a lookup in a text file, but this way should be backward-compatible with current programs.
What do you people think of this? I think this would be a great leap in usability for Linux. If this is implemented, I just may switch to Linux as my main OS. |
|
Back to top |
|
|
dice Guru
Joined: 21 Apr 2002 Posts: 577
|
Posted: Mon Dec 22, 2003 7:20 pm Post subject: |
|
|
Yeah but then you'd have to configure everything to use this 'autorun' |
|
Back to top |
|
|
itsr0y Tux's lil' helper
Joined: 22 Dec 2002 Posts: 81
|
Posted: Mon Dec 22, 2003 7:32 pm Post subject: |
|
|
Well, at first you would, but from then on if you want to change anything, you only have to change it in one place. Also, you don't have to remember which program does what, or any command-line switches.
This is more for the future of Gentoo, though. If this is implemented and becomes a common program, ebuilds can automatically set up programs to this 'autorun' automatically, and emerging new players and viewers automatically put themselves into /etc/autorun (or whatever it's called.) After time, Gentoo would ideally be at a point where the user should rarely, if ever, have to configure which program does what, unless of course he wants to. |
|
Back to top |
|
|
supernovus Apprentice
Joined: 13 Jul 2003 Posts: 150 Location: inside my head
|
Posted: Mon Dec 22, 2003 10:23 pm Post subject: |
|
|
I wrote something similar, called launch, but it only works on file extensions, no mime types, and it doesn't have more than one choice for each extension.
I'll have to dig it up again sometime, as I'd actually forgotten about it until this post came up. _________________ Remove OTW |
|
Back to top |
|
|
g1ul10 n00b
Joined: 01 Dec 2004 Posts: 11
|
Posted: Tue Jan 04, 2005 1:12 am Post subject: |
|
|
You should try zsh. It's a quite sophisticated shell which, among an iniinity of features, has a module called zsh-mime-setup which allows the automatic association of programs to file extensions.
Try
and then read the man page
looking for the module above.
If you are interested, I can share my configuration (which is nothing special, however). |
|
Back to top |
|
|
placeholder Advocate
Joined: 07 Feb 2004 Posts: 2500
|
Posted: Tue Jan 04, 2005 4:00 am Post subject: |
|
|
I do not mind telling something what I want to use, and I do not have many programs that ask for this anyway. I just cannot see how there is anything great about this feature of Windows when I can set the run action in ROX for all files and that is one of the only things that needs to know. The rest of stuff that needs to know is easy to configure, so I do not care. Then again, I also like control.
If you really care to do this then it would only take minimal knowledge of something like Python. |
|
Back to top |
|
|
placeholder Advocate
Joined: 07 Feb 2004 Posts: 2500
|
Posted: Tue Jan 04, 2005 6:05 am Post subject: |
|
|
Here is a concept version of the Python script require for this:
Code: | #!/usr/bin/env python
import os
import re
import string
import sys
musicPlayer = "beep-media-player"
imageViewer = "gqview"
audioTypes = "mp3|ogg|mpc|flac|mp3|m3u|pls|wav|wma"
imageTypes = "png|jpg|tiff|bmp|gif"
def main():
filename = sys.argv[1]
if re.search(audioTypes, string.lower(filename)) > 0:
os.system(musicPlayer + " \"" + filename + "\"")
if re.search(imageTypes, string.lower(filename)) > 0:
os.system(imageViewer + " \"" + filename + "\"")
if __name__ == "__main__":
main() |
It would not take much to complete it, and so far it works perfectly for audio and images. |
|
Back to top |
|
|
fuji Tux's lil' helper
Joined: 26 Apr 2002 Posts: 111
|
Posted: Tue Jan 04, 2005 6:36 am Post subject: Re: Automatic File-extension / Mime-type launcher |
|
|
itsr0y wrote: | (snip)
I know that KDE and GNOME programs act like Windows (somewhat), but still, I have to set up both KDE and GNOME, and I still have to set up non-KDE, non-GNOME programs. This is a major pain in the ass. |
I'm curious why you're willing to properly set up your `autorun` script but not the mime handling offered by KDE or GNOME. It doesn't take long (in KDE). In fact, KDE's mimetype handling is very robust. Just about everything you've asked for can be done or is done already in KDE.
Now if you don't want to use KDE and use one of the boxes, you're still going to need a filemanager. Doesn't ROX offer file associations? In my opinion you're re-implementing features that already exist. |
|
Back to top |
|
|
John5788 Advocate
Joined: 06 Apr 2004 Posts: 2140 Location: 127.0.0.1
|
Posted: Tue Jan 04, 2005 6:52 am Post subject: |
|
|
maybe /etc/mailcap can do something? _________________ John5788 |
|
Back to top |
|
|
bradenm n00b
Joined: 01 Jul 2004 Posts: 26 Location: Kelowna, BC, Canada
|
Posted: Fri Jan 07, 2005 3:29 am Post subject: |
|
|
Freedesktop.org already has a specification for detecting MIME types and they are working on a shared way of associating programs with each MIME type.
Seeing as how ROX, GTK, and GNOME already use the Shared MIME spec, and KDE and XFCE will be using it soon, this is where any interoperability will come from.
The shared MIME spec has C, python, perl, PHP, and ruby implementations so should be easy to utilize in any scripts/apps you might wish to make. |
|
Back to top |
|
|
revertex l33t
Joined: 23 Apr 2003 Posts: 806
|
Posted: Tue Jan 11, 2005 12:27 am Post subject: Re: Automatic File-extension / Mime-type launcher |
|
|
itsr0y wrote: | One of the reasons I use Windows and not Linux is because Windows is more integrated. In Windows, I set up which program is my video player once, and every program uses that video player (mostly). In Linux, though, I have to set up each program to use a specific program for a specific function. That is, in, let's say, my newsreader, I have to tell it which program is my web browser, my media player, my video player, my pdf viewer, my printer, etc. I know that KDE and GNOME programs act like Windows (somewhat), but still, I have to set up both KDE and GNOME, and I still have to set up non-KDE, non-GNOME programs. This is a major pain in the ass. |
man seriously i think this joke the most funniest that i have read in these forums.
which windows version are you using that there's something "more integerated"?
the mswindows that i know is completely a mess, if i set player "A" to be my default mp3 player and install or upgrade player "b", "c" and "d" surely one of these will be my new "defult" mp3 player without my permission.
In linux box xmms even play all music and mplayer play all video like i wish.
As fluxbox user i can't remember that i need to set something in gnome or kde, it just work, and that is why people love both. |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|