Skip to content

Commit

Permalink
Reimplement without python
Browse files Browse the repository at this point in the history
  • Loading branch information
alyosha committed Sep 13, 2020
1 parent 82ce232 commit 8f97f77
Show file tree
Hide file tree
Showing 16 changed files with 271 additions and 308 deletions.
4 changes: 1 addition & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
__pycache__
*.pyc
tags
docs/tags
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ that lazy
![vimedia statusline](statusline.png)

In addition to displaying track/artist information in your statusline, you can also navigate
through your media libraries, control volume, etc. using the following commands.
through your media libraries, control volume, etc. using the following commands. Still slightly
experimental until all base functionality has been implemented.

## Usage
- `:Play` => Begin playback from active media player
- `:Pause` => Pause playback from active media player
- `:PauseAll` => Pause playback from all running media players
- `:Skip` => Skip to next song
- `:Prev` => Go back to previous song
- `:Restart` => Replay current song from the beginning
- `:Shuffle` => Toggle shuffle for the media player
- `:Mute` => Mute audio for all media players
- `:Unmute` => Unmute audio for all media players
Expand All @@ -36,13 +36,13 @@ from within Vim to get a list of options (remember the players need to be runnin

## Coming soon
- Seek forward/backwards
- Restart
- Hard previous (instead of just restarting when playback is past a certain point)
- Make status bar optional

Suggestions/contributions welcome.

## Installation
Using your preferred plugin manager or if all else fails:

`git clone https://github.com/alyosha/vimedia ~/.vim/bundle/vimedia`

You may need to install a newer version of Vim if yours wasn't built with python3.
`git clone https://github.com/alyosha/vimedia ~/.vim/bundle/vimedia`
7 changes: 7 additions & 0 deletions dbus/control_playback
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

dbus-send --session \
--dest=$1 \
--print-reply \
/org/mpris/MediaPlayer2 \
org.mpris.MediaPlayer2.Player.$2
8 changes: 8 additions & 0 deletions dbus/get_active_players
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash

dbus-send --session \
--dest=org.freedesktop.DBus \
--type=method_call \
--print-reply \
/org/freedesktop/DBus \
org.freedesktop.DBus.ListNames | sed -ne '/MediaPlayer/{s/string//;s/^\s*//g;p}' | xargs | sed 's/\s/,/g'
22 changes: 22 additions & 0 deletions dbus/get_metadata
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash

case $2 in
"Title")
sed_pattern="/title/{n;s/string //;s/variant//;s/\"//g;s/^\s*//g;p}"
;;
"Artist")
sed_pattern="/artist/{n;n;s/string //;s/\"//g;s/^\s*//g;p}"
;;
esac

if [ -z "$sed_pattern" ]; then
exit 1
fi

dbus-send \
--print-reply \
--dest=$1 \
/org/mpris/MediaPlayer2 \
org.freedesktop.DBus.Properties.Get \
string:'org.mpris.MediaPlayer2.Player' \
string:'Metadata' | sed -ne "$sed_pattern"
25 changes: 25 additions & 0 deletions dbus/get_property
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash

case $2 in
"Volume")
sed_pattern="/double/{s/[[:alpha:]-]//g;s/^\s*//g;p}"
;;
"Shuffle")
sed_pattern="/boolean/{s/variant//g;s/boolean//g;s/^\s*//g;p}"
;;
"Position")
sed_pattern="s/^.*int64 //p"
;;
esac

if [ -z "$sed_pattern" ]; then
exit 1
fi

dbus-send \
--print-reply \
--dest=$1 \
/org/mpris/MediaPlayer2 \
org.freedesktop.DBus.Properties.Get \
string:'org.mpris.MediaPlayer2.Player' \
string:$2 | sed -ne "$sed_pattern"
7 changes: 7 additions & 0 deletions dbus/quit
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

dbus-send --session \
--dest=$1 \
--print-reply \
/org/mpris/MediaPlayer2 \
org.mpris.MediaPlayer2.Quit
5 changes: 3 additions & 2 deletions plugin/jobs/get_position → dbus/set_property
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ dbus-send \
--print-reply \
--dest=$1 \
/org/mpris/MediaPlayer2 \
org.freedesktop.DBus.Properties.Get \
org.freedesktop.DBus.Properties.Set \
string:'org.mpris.MediaPlayer2.Player' \
string:'Position' | sed -n -e 's/^.*int64 //p'
string:$2 \
variant:$3:$4
9 changes: 0 additions & 9 deletions plugin/jobs/get_artist

This file was deleted.

9 changes: 0 additions & 9 deletions plugin/jobs/get_title

This file was deleted.

Loading

0 comments on commit 8f97f77

Please sign in to comment.