You are not logged in.
Yesterday i tried (once again) to get xdg-open to do anything usefull. Without any DE installed, that was not so easy. Well, mayby i just did understand what to do. Anyway.
After a bit of research i found that xdg-open will use mimeopen, but only for local files, wverything else will be opened in Firefox. Or whatever Browser $BROWSER is set to.
I did not liked that. So i tinkered a bit with xdg-open.
Now one can create a simple File $XDG_CONFIG_HOME/mimeapp, like this:
pdf mupdf
jpg jpeg gif png tiff bmp sxiv
x-bzip-compressed-tar x-compressed-tar application/zip squeeze --class "DWM-TAG8"
http https list luakit firefox
local tuxcmd
Every line begins with a space seperated list of mime types (full or only the last bit), and, seperated by a tab, an application to open the file with. It is also possible to define a space seperated list of applications (prepened by "list"). Dmenu is then used to select one of them.
Here is the diff:
435c435
< open_generic_mimeapps()
---
> open_generic()
437,447c437,446
< mime=$(file -izb "$1" | sed 's/;.*//g')
< app=`grep $mime $XDG_CONFIG_HOME/mimeapps | cut -f 2`
< if [ "$app" = "" ]; then
< ft=$(echo $mime | sed 's#.*/##g')
< app=`grep $ft $XDG_CONFIG_HOME/mimeapps | cut -f 2`
< fi
< if [ $app != "" ]; then
< command_exec=`which $app 2>/dev/null`
< $command_exec "$1"
< if [ $? -eq 0 ]; then
< exit_success
---
> # Paths or file:// URLs
> if (echo "$1" | grep -q '^file://' ||
> ! echo "$1" | egrep -q '^[a-zA-Z+\.\-]+:'); then
>
> local file="$1"
>
> # Decode URLs
> if echo "$file" | grep -q '^file:///'; then
> file=${file#file://}
> file="$(printf "$(echo "$file" | sed -e 's@%\([a-f0-9A-F]\{2\}\)@\\x\1@g')")"
449,450c448
< fi
< }
---
> check_input_file "$file"
452,455c450,458
< open_generic_mimehandler()
< {
< handler=$(echo "$1" | sed 's#://.*##g')
< app=`grep $handler $XDG_CONFIG_HOME/mimeapps | cut -f 2`
---
> open_generic_xdg_mime "$file"
>
> if [ -f /etc/debian_version ] &&
> which run-mailcap 2>/dev/null 1>&2; then
> run-mailcap --action=view "$file"
> if [ $? -eq 0 ]; then
> exit_success
> fi
> fi
457,465c460,461
< if [ "x$app" != "x" ]; then
< if (echo "$app" | grep -q '^list '); then
< app=$(echo "$app" | sed 's/^list //g' | tr ' ' '\012' | dmenu $DMENUSETTINGS -p "Open $file with: ")
< #| zenity --list --title "Select Application" --text "Select Application to run $1" --column "Applications"
< fi
<
< if [ "x$app" != "x" ]; then
< command_exec=`which $app 2>/dev/null`
< $command_exec "$1"
---
> if mimeopen -v 2>/dev/null 1>&2; then
> mimeopen -L -n "$file"
467c463
< exit_success
---
> exit_success
469c465
< fi
---
> fi
471d466
< }
473,475c468,475
< open_generic()
< {
< local file="$1"
---
> IFS=":"
> for browser in $BROWSER; do
> if [ x"$browser" != x"" ]; then
>
> browser_with_arg=`printf "$browser" "$1" 2>/dev/null`
> if [ $? -ne 0 ]; then
> browser_with_arg=$browser;
> fi
477,481c477,480
< # Decode local file URLs
< if echo "$file" | grep -q '^file:///'; then
< file=${file#file://}
< file="$(printf "$(echo "$file" | sed -e 's@%\([a-f0-9A-F]\{2\}\)@\\x\1@g')")"
< fi
---
> if [ x"$browser_with_arg" = x"$browser" ]; then
> "$browser" "$1";
> else eval '$browser_with_arg'$xdg_redirect_output;
> fi
483,489d481
< if (echo "$file" | egrep -q '^[a-zA-Z0-9]+://'); then
< open_generic_mimehandler "$file"
< elif [ -d "$file" ]; then
< app=`grep 'local' $XDG_CONFIG_HOME/mimeapps | cut -f 2`
< if [ $app != "" ]; then
< command_exec=`which $app 2>/dev/null`
< $command_exec "$1"
491c483
< exit_success
---
> exit_success;
494,495c486
< else
< check_input_file "$file"
---
> done
497,499d487
< open_generic_mimeapps "$file"
< fi
<
*edit* If anyway knows of a better way to achieve something like this, without patching xdg-open*, i would really appreciate it
* I dont mind doing that, but i dont think this patch will ever come upstream, so it has to be applied after every update.
Last edited by 0mark (2011-07-18 10:55:13)
Ceterum autem censeo Systemdinem esse delendam
Offline
*edit* If anyway knows of a better way to achieve something like this, without patching xdg-open*, i would really appreciate it
* I dont mind doing that, but i dont think this patch will ever come upstream, so it has to be applied after every update.
You can basically (if not exactly) do this with mimeo.
*edit: take a look at mimeo's association files*
Last edited by Xyne (2011-07-19 00:26:55)
My Arch Linux Stuff • Forum Etiquette • Community Ethos - Arch is not for everyone
Offline
You can basically (if not exactly) do this with mimeo.
Yepp, works great, thanks
But i was looking for a way to make all (or most, at least some) Applications to use my defaults to open urls and files. I got the understanding that most are using xdg-open for this task. Only after i hacked xdg-open, i noticed that only one of the Programs i tested so far is actually using xdg-open. So the whole point of this is now spoiled.
Or am i missing something?
PS: I think this Thread might not fitting "community contributions" anymore, as it seems to be useless now. Sorry for that.
Ceterum autem censeo Systemdinem esse delendam
Offline
As far as I know, without some centralized configuration manager, you have to configure each application to use the opener of your choice. Usually there's some simple way to do it in the application's preferences dialogue.
My Arch Linux Stuff • Forum Etiquette • Community Ethos - Arch is not for everyone
Offline
Allan-Volunteer on the (topic being discussed) mailn lists. You never get the people who matters attention on the forums.
jasonwryan-Installing Arch is a measure of your literacy. Maintaining Arch is a measure of your diligence. Contributing to Arch is a measure of your competence.
Griemak-Bleeding edge, not bleeding flat. Edge denotes falls will occur from time to time. Bring your own parachute.
Offline