Skip to content

Instantly share code, notes, and snippets.

@shapr
Created September 19, 2022 00:15
Show Gist options
  • Save shapr/009492f6dd723d993c717431dbbe1fce to your computer and use it in GitHub Desktop.
Save shapr/009492f6dd723d993c717431dbbe1fce to your computer and use it in GitHub Desktop.
Shae's old elisp code
;;; mpc.el --- quick hack to make remote control bindings for mpd via the mpc client
; started out as xmms-shell, became alsaplayer-shell, is now mpc
;; copyright (C) 2005 Shae Matijs Erisson
;; released under the Lesser GPL license.
;; Author: Shae Erisson <[email protected]>
;; Keywords: multimedia mpc mpd fnord mp3 eris ogg flac
;; Version: 0.3
;; X-CVS: $Id: mpc.el,v 0.3 2005/45/15 25:26:11 shae Exp $
;;; Commentary:
; oboy, not again!
;;; Todo:
; direct tcp/ip signals instead of shell script wrapper?
;;; Code:
(defun msc (cmd) `(lambda () (interactive) (message (shell-command-to-string ,cmd))))
; cool code by kensanata (Alex Schroeder)
(defun msc (cmd) `(lambda () (interactive)
(message
(replace-regexp-in-string "
" "" (replace-regexp-in-string "%" "%%" (shell-command-to-string ,cmd)
)))))
; I don't know how to make this into a macro
(defun mpc-playlist-jump (num) (interactive "snum? ")
"Jump to a certain index in the playlist
The ap_playlist_save command should save the current playlist into
~/.alsaplayer/alsaplayer.m3u"
(shell-command-to-string (concat "mpc play " num)))
; hyperactivity?
; I like the Hyper key
; here's what I'm using at the moment
; note that I actually call this defun in my .emacs
; so when you put it in your own keybindings, you'll need to execute it yourself
(defun mpc-shell-keymap () (interactive)
(progn
(global-set-key [(hyper down)] (msc "mpc volume -5"))
(global-set-key [(hyper up)] (msc "mpc volume +5"))
(global-set-key [(hyper right)] (msc "mpc next"))
(global-set-key [(hyper left)] (msc "mpc prev"))
(global-set-key [(super left)] (msc "mpc seek -7"))
(global-set-key [(super right)] (msc "mpc seek +7"))
(global-set-key [(hyper b)] (msc "mpc toggle"))
(global-set-key [(hyper j)] 'mpc-playlist-jump)
(global-set-key [(hyper x) (i)] (msc "mpc")) ; i = info?
(global-set-key [(hyper x) (p)] (msc "mpc play"))
(global-set-key [(hyper x) (s)] (msc "mpc stop"))
(global-set-key [(hyper x) (t) (r)] (msc "mpc random"))
))
(provide 'mpc)
;; mpc ends here
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment