You are not logged in.

#1 2012-07-02 20:26:20

Cloudef
Member
Registered: 2010-10-12
Posts: 636

linopen - Yet another xdg-open replacement

Inspired by Taylorchu's mimi, I decided to make xdg-open replacement written in bash that has somewhat flexible configuration.
You can match either, extensions, mime types, mime groups, or regular expressions of the filename.
You can also specify applications that you wish to open in terminal, and linopen knows when the process should be opened in new terminal or in your current open terminal.

Example configuration

#
# linopen configuration
# enviroiment variables can be used
#

# Specify your terminal emulator here
# for terminal support.
terminal=xterm

# Specify all programs you want to
# open in terminal like this:
interm=vim

# There are 4 ways to match filetypes.
# The following examples are in the order
# which linopen chooses the program as well.

# 1. File extension
# .png:sxiv
# .mp4:mplayer
# .txt:vim

# 2. Mime type
# image/png:sxiv
# video/mp4:mplayer
# text/plain:vim

# 3. Mime category
image:sxiv
video:mplayer
audio:mplayer->interm # you can also specify the interm rule explictly after '->'
text:vim

# 4. Regexp
# Match some protocols by default
?'^http:\/\/':$BROWSER
?'^https:\/\/':$BROWSER
?'^www.':$BROWSER

# Directory rule for directories
# ideally you want to use file manager
# here if you are a GUI user.
directory:echo

# Default rule just echoes back whatever
# was feed. If you are using DE you could
# just map a file manager here and it would
# integrate with your system.
default:echo

PKGBUILD here

Refer to the configuration file for more detailed how-to.
There is also 'open' symlink to xdg-open to emulate Mac Os X behaviour.

Last edited by Cloudef (2012-07-17 16:08:41)

Offline

#2 2012-07-03 09:20:51

Army
Member
Registered: 2007-12-07
Posts: 1,784

Re: linopen - Yet another xdg-open replacement

Very nice!!

Just one thing, in your PKGBUILD the md5sum of open seems to be wrong.

Offline

#3 2012-07-03 15:30:33

Cloudef
Member
Registered: 2010-10-12
Posts: 636

Re: linopen - Yet another xdg-open replacement

Army wrote:

Just one thing, in your PKGBUILD the md5sum of open seems to be wrong.

Funny, the open should be symlink to the xdg-open. The PKGBUILD certainly works here.

Offline

#4 2012-07-03 15:51:06

Army
Member
Registered: 2007-12-07
Posts: 1,784

Re: linopen - Yet another xdg-open replacement

In this case it would be better to change the PKGBUILD to this

# Maintainer: Cloudef <mailroxas@gmail.com>
# Intelligent and suckless replacement for xdg-open

pkgname=linopen
pkgver=1.0
pkgrel=1
pkgdesc='Intelligent and suckless replacement for xdg-open'
arch=('any')
url='http://cloudef.eu'
license=('WTFPL')
provides=('xdg-utils')
conflicts=('xdg-utils')
backup=('etc/linopen.conf')
source=('xdg-open' 'linopen.conf')

package() {
   cd "$srcdir"
   mkdir -p "${pkgdir}/usr/bin"
   mkdir -p "${pkgdir}/etc"
   ln -s "/usr/bin/xdg-open" "$pkgdir/usr/bin/open"
   install -m755 xdg-open "${pkgdir}/usr/bin/"
   install -m755 linopen.conf "${pkgdir}/etc/"
}
md5sums=('f5487fc4c305a20124da7bb164e6b04d'
         '2c9078f3ee82d619dc150bb44837d9e8')

or (imho nicer) with this package function

package() {
	install -Dm755 "$srcdir/xdg-open" "${pkgdir}/usr/bin/xdg-open"
	install -Dm755 "$srcdir/linopen.conf" "${pkgdir}/etc/linopen.conf"
	ln -s "/usr/bin/xdg-open" "$pkgdir/usr/bin/open"
}

Last edited by Army (2012-07-03 16:04:13)

Offline

#5 2012-07-03 16:04:12

ninian
Member
From: United Kingdom
Registered: 2008-02-24
Posts: 696
Website

Re: linopen - Yet another xdg-open replacement

Cloudef wrote:

Inspired by Taylorchu's mimi, I decided to make xdg-open replacement ... and linopen knows when the process should be opened in new terminal or in your current open terminal.

Love it when one program inspires another, especially if it improves upon it!
You've also got me thinking that I should add a 'run in terminal' option to my own opener, expro (reported earlier in the forum).
There is quite a collection of openers now - maybe they deserve a Wiki page in their own right (although mimeo is mentioned on the xdg-open page).
wink

Offline

#6 2012-07-03 16:04:33

Cloudef
Member
Registered: 2010-10-12
Posts: 636

Re: linopen - Yet another xdg-open replacement

Army wrote:

In this case it would be better to change the PKGBUILD to this

Done smile

You've also got me thinking that I should add a 'run in terminal' option to my own opener, expro (reported earlier in the forum).

As a tip, it might be possible to do automatic detection whether the program needs terminal at all, by checking what it is linked against with ldd. However it's not accurate. Especially if the program dynamically loads something. Best way I can think of is just defining manually on configuration, as the user knows the best.

Last edited by Cloudef (2012-07-03 16:06:31)

Offline

#7 2012-07-03 20:04:02

Cloudef
Member
Registered: 2010-10-12
Posts: 636

Re: linopen - Yet another xdg-open replacement

Just head ups, if someone started using it. The directory rule wasn't getting used at all and is now fixed.

Offline

#8 2012-07-17 12:33:15

Army
Member
Registered: 2007-12-07
Posts: 1,784

Re: linopen - Yet another xdg-open replacement

Feature request: I want to open video files in mplayer, but audio files as well. For audio files, I want mplayer to start in a terminal, for video files I don't. As far as I can see this isn't possible right now. If it is, please give me a heads up.

Offline

#9 2012-07-17 16:06:58

Cloudef
Member
Registered: 2010-10-12
Posts: 636

Re: linopen - Yet another xdg-open replacement

Army wrote:

Feature request: I want to open video files in mplayer, but audio files as well. For audio files, I want mplayer to start in a terminal, for video files I don't. As far as I can see this isn't possible right now. If it is, please give me a heads up.

Good suggestion, I've added it to git now.
You can specify interm explictly for rule by appending '->interm' after program name. I also added output redirection for backgrouned applications to /dev/null.

Offline

#10 2012-07-18 11:06:35

Army
Member
Registered: 2007-12-07
Posts: 1,784

Re: linopen - Yet another xdg-open replacement

Awesome, now everything works very well. Thanks Cloudef!

Offline

#11 2012-07-19 18:53:44

Cloudef
Member
Registered: 2010-10-12
Posts: 636

Re: linopen - Yet another xdg-open replacement

Extension matching was actually broken whole time, pushed fix to git. Also gave echo command a exception, so it won't run in background (without interm) and it's output won't get redirect.

Offline

#12 2012-12-17 22:20:22

orschiro
Member
Registered: 2009-06-04
Posts: 2,136
Website

Re: linopen - Yet another xdg-open replacement

Hello I have a file with the extension .pez which I would like to open with prezi-desktop.

Thus, my linopen.conf

#
# linopen configuration
# enviroiment variables can be used
#

.pez:prezi-desktop

However, they are still opened with File Roller. Did I make something wrong?

Robert

Last edited by orschiro (2012-12-17 22:25:11)

Offline

#13 2012-12-17 22:35:30

Cloudef
Member
Registered: 2010-10-12
Posts: 636

Re: linopen - Yet another xdg-open replacement

orschiro wrote:

Hello I have a file with the extension .pez which I would like to open with prezi-desktop.

Seems to work fine here.
Can you post your `pacman -Q linopen` and is that your full config?
linopen.conf requires default rule as fallback.

This should be the output with your config:

─┬╼ .loli//LOLI :: /home/loli
 └╼ ] open -c asd.conf asd.pez
rule must exist in configuration: 'default:'

Last edited by Cloudef (2012-12-17 22:36:58)

Offline

#14 2012-12-17 22:39:35

orschiro
Member
Registered: 2009-06-04
Posts: 2,136
Website

Re: linopen - Yet another xdg-open replacement

[orschiro@thinkpad ~]$ pacman -Q linopen
linopen 1.4-2

Sorry, I was incorrect about the config. It is .linopenrc. I left the default one in /etc untouched.

Screenshot

EDIT:

The output is the same:

[orschiro@thinkpad ~]$ open -c .linopenrc testfile.pez 
rule must exist in configuration: 'default:'

But why is it still opened with File Roller (see screenshot)?

Last edited by orschiro (2012-12-17 22:41:08)

Offline

#15 2012-12-17 22:47:46

Cloudef
Member
Registered: 2010-10-12
Posts: 636

Re: linopen - Yet another xdg-open replacement

But why is it still opened with File Roller (see screenshot)?

Because linopen does not work that way. It does not integrate with gnome or gnome-open stuff.
It's replacement for xdg-open, without all the weird mime files and .desktop stuff.

To use the linopen in your filemanager, you would need to have .desktop file that calls 'xdg-open %f' and it would choose the program to open it according to how linopen is configured.

If you use DE integration, I would recommend to set up things their way. I'm sure nautilus allows you to configure .pez files to open in prezi-desktop.

Offline

#16 2012-12-17 22:56:25

orschiro
Member
Registered: 2009-06-04
Posts: 2,136
Website

Re: linopen - Yet another xdg-open replacement

Thanks Cloudef. At least now it is clear in what cases to use xdg-open tools. I may find another solution for Gnome.

Offline

#17 2012-12-20 03:54:00

Supplantr
Member
From: a state of sunshine
Registered: 2011-12-12
Posts: 149
Website

Re: linopen - Yet another xdg-open replacement

The presence of ~/.linopenrc seems to cause xdg-open to fail in certain situations. Specifying with -c either /etc/linopen.conf or ~/.linopenrc works. I remedied this by changing line 17 to:

[[ -f "$_LINOPEN_CFGRC" ]] && { egrep -v "^(#|$)" "$_LINOPEN_CFGRC"; return; }

I use linux and I dont understand nothing in this post.

Offline

#18 2012-12-20 08:45:22

Cloudef
Member
Registered: 2010-10-12
Posts: 636

Re: linopen - Yet another xdg-open replacement

Supplantr wrote:

The presence of ~/.linopenrc seems to cause xdg-open to fail in certain situations. Specifying with -c either /etc/linopen.conf or ~/.linopenrc works. I remedied this by changing line 17 to:

[[ -f "$_LINOPEN_CFGRC" ]] && { egrep -v "^(#|$)" "$_LINOPEN_CFGRC"; return; }

It seems to fail, if /etc/linopen.conf exists looking at the scripts logic.
I'll push a fix for this when I'm off from work. Thanks!

Offline

#19 2013-01-05 00:02:29

Cloudef
Member
Registered: 2010-10-12
Posts: 636

Re: linopen - Yet another xdg-open replacement

It seems I totally forgot this issue until someone reported it again on github.
There should be fix now.

Offline

Board footer

Powered by FluxBB