You are not logged in.

#1 2012-02-06 06:58:10

taylorchu
Member
Registered: 2010-08-09
Posts: 405

mimi: a dead simple replacement for xdg-open

actually, I think you dont need xdg-utils anymore.

repo:https://github.com/taylorchu/mimi
aur:https://aur.archlinux.org/packages.php?ID=56438

important
how to setup default application

create a file ~/.config/mimi/mime.conf
in this file, it is your time to be creative

this is what i have:

text/html: chromium
image/png:feh
image/*:feh

note: you have to put "default" in this file. it should be a file manager. mimi will try to call the file manager to open the file's path if you did not tell mimi who to call!

Enjoy!!

Last edited by taylorchu (2012-11-29 09:56:17)


"After you do enough distro research, you will choose Arch."

Offline

#2 2012-02-06 08:06:57

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

Re: mimi: a dead simple replacement for xdg-open

Good idea!

I edited it a bit to handle websites

# $1 = Program
# $2 = Filename
launch() {
   program="$1"
   [ "$program" ] || program="$(grep "^default:" "$CONFIG" | cut -d : -f 2)"
   "$program" "$2"
   exit 0
}

CONFIG="$HOME/.config/mimi/mime.conf"  
main() {
   [[ -f "$CONFIG" ]] || err "No configuration file found."

   filename="$@"
   if [[ ! -f "$filename" ]]; then
      [[ "$filename" == http://* ]] && launch "$BROWSER" "$filename"
      [[ "$filename" == www.* ]]    && launch "$BROWSER" "$filename"
      filename=${filename##file://}
      [[ -d "$filename" ]] || [[ -f "$filename" ]] || err "The file does not exist."
      launch "" "$filename" # it's a directory or file with file:// syntax, try launching with 'default'    
   fi
   ext=${filename##*.}
   path=${filename%/*}
   program=$(grep "^$ext:" "$CONFIG" | cut -d : -f 2)

   launch "$program" "$filename"
}
main "$@" 

E: Only check website if file does not exist (you can have file called www.google.fi, if you want)
E2: Add the missing bits and make it handle file:// syntax too, also make it open directories

Last edited by Cloudef (2012-02-06 09:01:15)

Offline

#3 2012-02-06 09:30:29

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

Re: mimi: a dead simple replacement for xdg-open

Nice idea! I'll give it a try!

Offline

#4 2012-02-06 12:32:31

Earnestly
Member
Registered: 2011-08-18
Posts: 805

Re: mimi: a dead simple replacement for xdg-open

Just wanted to say thank you.

Being able to explicitly enable certain behavior instead of it trying to guess is exactly what I've been looking for.
Now I can choose what opens with what and build the list as I intend.

Thank you smile

Last edited by Earnestly (2012-02-06 12:36:43)

Offline

#5 2012-02-06 20:00:37

Sirsurthur
Member
Registered: 2009-02-02
Posts: 124

Re: mimi: a dead simple replacement for xdg-open

Very nice idea ! Will look into it !

Thanks smile

Offline

#6 2012-02-07 00:19:20

ShadowKyogre
Member
From: Hell! XP No... I'm not telling
Registered: 2008-12-19
Posts: 476
Website

Re: mimi: a dead simple replacement for xdg-open

This looks pretty interesting especially since I don't have Thunar on my laptop. I edited it a bit to include Clouddef's modification and additional mime-type support detected using file.

# $1 = Program
# $2 = Filename
launch() {
   program="$1"
   [ "$program" ] || program=$(grep "^$(file -b --mime-type ${2}):" "$CONFIG" | cut -d : -f 2) \
    || program="$(grep "^default:" "$CONFIG" | cut -d : -f 2)"
   "$program" "$2"
   exit 0
}

CONFIG="$HOME/.config/mimi/mime.conf"  
main() {
   [[ -f "$CONFIG" ]] || err "No configuration file found."

   filename="$@"
   if [[ ! -f "$filename" ]]; then
      [[ "$filename" == http://* ]] && launch "$BROWSER" "$filename"
      [[ "$filename" == www.* ]]    && launch "$BROWSER" "$filename"
      filename=${filename##file://}
      [[ -d "$filename" ]] || [[ -f "$filename" ]] || err "The file does not exist."
      launch "" "$filename" # it's a directory or file with file:// syntax, try launching with 'default'    
   fi
   ext=${filename##*.}
   path=${filename%/*}
   program=$(grep "^$ext:" "$CONFIG" | cut -d : -f 2)

   launch "$program" "$filename"
}
main "$@" 

For every problem, there is a solution that is:
Clean
Simple and most of all...wrong!
Github page

Offline

#7 2012-02-07 05:15:14

taylorchu
Member
Registered: 2010-08-09
Posts: 405

Re: mimi: a dead simple replacement for xdg-open

i dont like mime so much because it needs to be looked up. in contrast, file ext is so easy to setup.
this app will be included in my live cd: march, along with "3x+ battery life configuration".

did anyone try to contact xdg-open's author? original xdg-open does not work really well.


"After you do enough distro research, you will choose Arch."

Offline

#8 2012-03-22 17:38:29

FrozenCow
Member
Registered: 2011-02-03
Posts: 19

Re: mimi: a dead simple replacement for xdg-open

I know this is an old thread, hopefully no one minds tongue.
I really like this xdg-util alternative. I don't have to check what the mimetype is of certain files and it doesn't confuse the many different types of xml-like files.
There were just 2 features that lacked imo, directories and urls, so I've added them (https://github.com/taylorchu/mimi/pull/1). Could you pull these features in?

Offline

#9 2012-03-22 17:42:41

Xyne
Administrator/PM
Registered: 2008-08-03
Posts: 6,963
Website

Re: mimi: a dead simple replacement for xdg-open

taylorchu wrote:

did anyone try to contact xdg-open's author? original xdg-open does not work really well.

No, but I wrote Mimeo. wink


My Arch Linux StuffForum EtiquetteCommunity Ethos - Arch is not for everyone

Offline

#10 2012-03-23 02:29:27

taylorchu
Member
Registered: 2010-08-09
Posts: 405

Re: mimi: a dead simple replacement for xdg-open

@FrozenCow
thanks so much.

some changes since we have the first release.

1. add "directory": this keyword handles a folder.
2. add support for protocol:

ftp:filezilla # can be run as "xdg-open ftp://somewebsite..."
http:firefox
magnet:urxvt -e rtorrent # support for magnet links; so awesome

Last edited by taylorchu (2012-03-23 02:29:41)


"After you do enough distro research, you will choose Arch."

Offline

#11 2012-03-23 09:35:41

el mariachi
Member
Registered: 2007-11-30
Posts: 595

Re: mimi: a dead simple replacement for xdg-open

is there a way of making pcmanfm respect this? will shellfm?
otherwise -- awesome !

Offline

#12 2012-03-23 14:21:26

Demon
Member
From: Republic of Srpska, BA
Registered: 2008-03-02
Posts: 246

Re: mimi: a dead simple replacement for xdg-open

I would gladly get rid of xdg-utils, but:

% pacqi xdg-utils
Name           : xdg-utils
...
Required By    : libreoffice-common  qt  skype
...

Offline

#13 2012-03-23 14:32:49

el mariachi
Member
Registered: 2007-11-30
Posts: 595

Re: mimi: a dead simple replacement for xdg-open

@Demon: I don't have xdg-utils and I do use libreoffice-common and qt :S

Offline

#14 2012-03-23 16:16:29

taylorchu
Member
Registered: 2010-08-09
Posts: 405

Re: mimi: a dead simple replacement for xdg-open

@el mariachi
it only affects programs that use xdg-open.


"After you do enough distro research, you will choose Arch."

Offline

#15 2012-04-05 09:45:47

theGunslinger
Member
Registered: 2011-05-20
Posts: 300

Re: mimi: a dead simple replacement for xdg-open

Is there any way to make dwb use mimi for loading magnet links?

Offline

#16 2012-04-13 10:52:36

Mektub
Member
From: Lisbon /Portugal
Registered: 2008-01-02
Posts: 647

Re: mimi: a dead simple replacement for xdg-open

I am not able to install mimi from the Aur.

I get:

packer -S mimi
==> Determining latest git revision...
  -> Version found: 20120413
==> Making package: mimi 20120413-1 (Sex Abr 13 11:47:49 WEST 2012)
==> Checking runtime dependencies...
==> Checking buildtime dependencies...
==> Retrieving Sources...
==> Extracting Sources...
==> Removing existing pkg/ directory...
==> Entering fakeroot environment...
==> Starting build()...
==> Connecting to GIT server....
fatal: working tree '/home/tanso' already exists.
==> ERROR: A failure occurred in build().
    Aborting...
The build failed.

Am I doing something wrong ? /home/tanso is my HOME directory.

Mekyub


Follow me on twitter: https://twitter.com/johnbina

Offline

#17 2012-04-13 17:12:29

taylorchu
Member
Registered: 2010-08-09
Posts: 405

Re: mimi: a dead simple replacement for xdg-open

@Mektub
There is something wrong with your git. I am really sure.

@everyone
now support files with no extension

:urxvt -e vim

This means that when there is no extension, call urxvt and run vim
previously the code has some bugs to prevent the behavior.


"After you do enough distro research, you will choose Arch."

Offline

#18 2012-04-13 23:36:14

Mektub
Member
From: Lisbon /Portugal
Registered: 2008-01-02
Posts: 647

Re: mimi: a dead simple replacement for xdg-open

taylorchu wrote:

@Mektub
There is something wrong with your git. I am really sure.

taylorchu,

you were absolutely right. I had several variables initialized from some testes I had done and completely forgotten.

Many thanks,

Mektub


Follow me on twitter: https://twitter.com/johnbina

Offline

#19 2012-04-27 03:44:38

Hspasta
Member
Registered: 2011-12-24
Posts: 189
Website

Re: mimi: a dead simple replacement for xdg-open

Very simple and convenient! I love it. smile

Offline

#20 2012-11-29 09:54:48

taylorchu
Member
Registered: 2010-08-09
Posts: 405

Re: mimi: a dead simple replacement for xdg-open

after being even more lazy these days, i released  version 2.0. now it is completely based on "file".
by default, you dont have to configure, because it will use .desktop file when you install new program. (also a smart method is provided. compared to original xdg-open, it is less likely to choose wrong app in this mode)

NOTE: the old config file does not work anymore. please use the newer format, which is shown in the first post.

Last edited by taylorchu (2012-11-29 09:57:15)


"After you do enough distro research, you will choose Arch."

Offline

#21 2012-11-30 14:24:25

theGunslinger
Member
Registered: 2011-05-20
Posts: 300

Re: mimi: a dead simple replacement for xdg-open

How does this new format work exactly, I guess i get it for text and image files but what about rar, zip, magnet? What do I put in front of those and how does it matter?

Offline

#22 2012-11-30 19:01:39

taylorchu
Member
Registered: 2010-08-09
Posts: 405

Re: mimi: a dead simple replacement for xdg-open

it is simply the result you get from running "file --mime-type $file"
you can google to find them out.


"After you do enough distro research, you will choose Arch."

Offline

#23 2012-11-30 20:56:13

asdf-chan
Member
Registered: 2011-10-23
Posts: 31

Re: mimi: a dead simple replacement for xdg-open

I like it, but I would recommend the use of 'mimetype -b $file'.

For example with *.mkv files, 'file --mime-type' returns application/octet-stream, instead of 'video/x-matroska'.

ps. I wanted to do a formal pull request but it seems GitHub is having problems right now :-(

Offline

#24 2012-12-19 17:21:00

taylorchu
Member
Registered: 2010-08-09
Posts: 405

Re: mimi: a dead simple replacement for xdg-open

@asdf-chan
file is more widely used.

@everyone
the script logic is completed rewritten. it is almost plug and play now!


"After you do enough distro research, you will choose Arch."

Offline

Board footer

Powered by FluxBB