SEARCH

Enter your search query in the box above ^, or use the forum search tool.

You are not logged in.

#1 2012-08-01 19:53:27

brontosaurusrex
#! Junkie
Registered: 2012-06-15
Posts: 479

mplayer from thunar

P L A Y

about:
This script is a middle man between thunar and mplayer. It will play one or many selected files via thunars custom action menu in a clean manner (always positioning mplayer window at the programed place on the screen) and it will exit smoothly. It can also be used directly from command line, as:

"play file.mp4"
or
"play file1.mp4 file2.mp4 ./folder/file3.mp4"
or
"play *.avi"

install:
a. put into /home/user/bin as "play" and "chmod +x play"
b. in thunar make custom action using the command "play %F"
c. customize the script, window position to your liking.

snaps:
https://www.dropbox.com/sh/jiev8g3gm6gsspq/dJW5SCzQBL

play:

#!/bin/bash

# play:
# version 0.2 (now uses percents all over the place)

# readme:
# this can be used as:
# store me in "~/bin" as "play" (chmod +x play) and 
# refer from thunar as custom action "play %F"

# make temporary folder and trap to clean up
TMPDIR=`mktemp -d`
trap "rm -rf $TMPDIR" EXIT

while [ $# -gt 0 ]; do

    # expand path, so this can be used from cli as well (on relative paths)
    expanded=$(readlink -f $1)
    
    # write line by line into temporary folder / playlist.txt
    echo $expanded >> "$TMPDIR"/playlist.txt
    shift
done

# calculate width in %
# get screen width in pixels
widthpx=`xrandr | grep "*" | sed -r 's/^([^.]+).*$/\1/; s/^[^0-9]*([0-9]+).*$/\1/'`
# get 47% of that (just some number, use what you need here)
percentpx=`echo "$widthpx*47/100" | bc`


# open playlist and play
mplayer -ontop -geometry 50%:5% -xy $percentpx -fixed-vo -playlist "$TMPDIR"/playlist.txt 


# mplayer additional options:
# -cache 20000 -cache-min 50    (over the wire)
# -loop 0                       (loop 4ever)
# -fs                           (full screen)
# -vo vdpau:deint=2             (deinterlace if vdpau is active)

# end

edit: version 0.2, now uses percents all over the place (no hardcoded pixels anymore), "resolution independent !"

nautilus:
one way to make this also work in nautilus (as nautilus script):
cd .gnome2/nautilus-scripts/
ln -s ~/bin/play

Last edited by brontosaurusrex (2012-08-06 18:37:29)

Offline

Help fund CrunchBang, donate to the project!

#2 2012-08-06 15:29:36

brontosaurusrex
#! Junkie
Registered: 2012-06-15
Posts: 479

Re: mplayer from thunar

P L A Y  N O T I F Y

playb: (no playlist, can popup nice notify windows on each file)

#!/bin/bash

# playb (no playlist)

# readme:
# this can be used as:
# store me in "~/bin" as "playb" (chmod +x play) and 
# refer from thunar as custom action "play %N"

# problem:
# mplayer seems to always exit with code 0, so there is no way of
# telling if it was user interacted, so there is also no way (i know) of 
# breaking out of the loop, you will have to press esc as many times as needed :P

# calculate width in %
# get screen width in pixels
widthpx=`xrandr | grep "*" | sed -r 's/^([^.]+).*$/\1/; s/^[^0-9]*([0-9]+).*$/\1/'`
# get 47% of that (just some number, use what you need here)
percentpx=`echo "$widthpx*47/100" | bc`

while [ $# -gt 0 ]; do

# expand path, so this can be used from cli as well (on relative paths)
expanded=$(readlink -f $1)
   
# notify-send
notify-send "$1"
    
# play
mplayer -ontop -geometry 50%:5% -xy $percentpx -fixed-vo "$expanded"


shift
done


# mplayer additional options:
# -cache 20000 -cache-min 50    (over the wire)
# -loop 0                       (loop 4ever)
# -fs                           (full screen)
# -vo vdpau:deint=2             (deinterlace if vdpau is active)

# end

snap: https://www.dropbox.com/s/fnafg23k5zgdf … notify.png

problems: no way I find to exit the loop on user interaction (You will have to press esc few times, no big deal).

Last edited by brontosaurusrex (2012-08-06 18:37:48)

Offline

#3 2012-08-06 15:42:23

rhowaldt
#!*$%:)
Registered: 2011-03-09
Posts: 4,396

Re: mplayer from thunar

looks nice bronto!

Offline

Board footer

Powered by FluxBB

Copyright © 2012 CrunchBang Linux.
Proudly powered by Debian. Hosted by Linode.
Debian is a registered trademark of Software in the Public Interest, Inc.

Debian Logo