Bind the mouse buttons in mpv
Merge branch 'readme'
Link to the .build.yml instead
My Python wrappers and around feh and mpv.
The package builds its own instances of forks of feh and mpv (feh, mpv) parametrizing the relevant XDG directories in order to obtain isolation from any already present configurations.
Other small features I've found useful are:
while feh ...; do ...; end
)These wrappers primarily evolved from my inability to remember the flags when switching from mplayer
to mplayer2
to mpv
.
My scheme being: one purposeful wrapper around whatever tool implements the functionality at the time:
play
, view
and edit
.
So when fashions change, the implementation changes not the facade (hey I remember this from the Gang of Four).
The Python wrappers evolved to being capable of triggering callbacks in the Python host program. The idea came from binding feh's action keys to use socat to sending back the trigger over a Unix socket.
Following are two examples binding actions/keys in feh and mpv to Python callbacks. These are tested (results) using xdotool and Xvfb.
import asyncio
import sys
from media.play import Player
sources = sys.argv[1:]
result = None
def sample_action(path, instance):
global result
result = True
instance.terminate()
actions = [
Player.Action(key="F1", f=sample_action),
]
async def amain():
async with Player(mute=True).run(sources, actions) as i:
rc = await i.wait()
asyncio.run(amain())
sys.exit(0 if result else 1)
import asyncio
import sys
from media.view import Viewer
sources = sys.argv[1:]
result = None
def sample_action(path, instance):
global result
result = True
instance.terminate()
actions = [
Viewer.Action(number=1, f=sample_action),
]
async def amain():
async with Viewer().run(sources, actions) as i:
rc = await i.wait()
asyncio.run(amain())
sys.exit(0 if result else 1)