Created
September 1, 2009 04:30
-
-
Save jonuts/178899 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ShellFM = function() { | |
const commands = ['skip', 'love', 'hate', 'pause', 'play']; | |
var shellsocket = liberator.globalVariables.shellsocket; | |
var socat = liberator.globalVariables.socat || "/usr/bin/socat"; | |
var runCommand = function(cmd) { | |
if (!shellsocket){ | |
liberator.echo("Set shellsocket with the path to your shell-fm UNIX socket"); | |
return; | |
} | |
var command = "silent !" + socat + " UNIX-CONNECT:" + shellsocket + " - <<<'" + cmd + "'"; | |
liberator.execute(command); | |
return; | |
}; | |
return { | |
skip: function(){ runCommand('skip' ) }, | |
love: function(){ runCommand('love' ) }, | |
hate: function(){ runCommand('ban' ) }, | |
pause: function(){ runCommand('pause') }, | |
play: function(){ | |
var station = prompt("Station to play:"); | |
var cmd = "play lastfm://" + station; | |
runCommand(cmd); | |
}, | |
completer: function(context) { | |
context.completions = [[c, ''] for each (c in commands)]; | |
} | |
}; | |
}(); | |
commands.add( | |
['ShellFM'], | |
'Control shell-fm from within vimperator', | |
function(cmd) {ShellFM[cmd].call()}, | |
{ count: true, argCount: 1, completer: ShellFM.completer } | |
); | |
mappings.add( | |
[modes.NORMAL], | |
["<Leader>sl"], | |
'Love track', | |
function() {ShellFM.love()} | |
) | |
mappings.add( | |
[modes.NORMAL], | |
["<Leader>sn"], | |
'Skip track', | |
function() {ShellFM.skip()} | |
) | |
mappings.add( | |
[modes.NORMAL], | |
["<Leader>sp"], | |
'Skip track', | |
function() {ShellFM.play()} | |
) | |
mappings.add( | |
[modes.NORMAL], | |
["<Leader>sP"], | |
'Skip track', | |
function() {ShellFM.pause()} | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment