Quantcast
Channel: Squeezebox : Community : Forums - 3rd Party Software
Viewing all articles
Browse latest Browse all 2059

Announce: LMS mini-controller, written in go

$
0
0
Hi all


I'd like to present you lms.go.

This is a tiny program/utility/library to interact with a Logitech Media Server and execute some actions from the CLI or from other programs. It should work at least on GNU/Linux machines. License is GPL 3+.

Lastly I've seen many libraries written in Python to manage LMS… well, I even confess I wrote one some years ago.
As I'm learning go nowdays I thought this could be a nice project, and nevertheless this code could be useful if anyone wants to create a complete library in go to manage LMS.

In my case, I map some keybindings on my computer to execute different tasks: toggle play/pause, volume up or down, and so on. Before I used my old python-based library, which I substituted with this new one go-based. Start times are faster.
You can see part of the configuration of my WM/DE (swaywm/i3) below[*].

Some use examples:

Code:

└→ $ ./lms server
ServerInfo{192.168.x.y:9002 v7.9.2  [115days 9h43m22s  S:43472 A:611 L:3344 G:92]  Players:3  Last scan: Tue, 23 Jun 2020 13:57:59}

└→ $ ./lms players
Player{⏹ ✘ Squeezebox Radio (baby) - XX:XX:XX:XX:XX:XX - 192.168.x.y:40043 - 0% - stop - No repeat, No shuffle, 0/0}
Player{⏹ ✔ Marantz NR1504 (squeezelite) - XX:XX:XX:XX:XX:XX - 127.0.0.1:47684 - 33% - stop - No repeat, No shuffle, 7/16}
Player{♫ ✔ Squeezebox (boom) - XX:XX:XX:XX:XX:XX - 192.168.x.z:37657 - 27% - play - No repeat, No shuffle, 45/135}

└→ $ ./lms status
|Squeezebox  27%| Thalia Zedek Band: Do You Remember [“Liars and Prayers”] - ♫ 4:25/5:47  [46/135]

└→ $ ./lms song
SongInfo{'Do You Remember' by Thalia Zedek Band (Liars and Prayers #3, 2008)  PC: 10  Rating: 70  ID: 418766}

└→ $ ./lms playlist
Squeezebox: 46/135
  Thalia Zedek Band: JJ85
  Thalia Zedek Band: House Of The Rising Sun
  Thalia Zedek Band: Eastern Hue
  Thalia Zedek Band: Next Exit
  Thalia Zedek Band: Lower Allston
♫ Thalia Zedek Band: Do You Remember
  Thalia Zedek Band: We Don't Go
  Thalia Zedek Band: Body Memory
  Thalia Zedek Band: Wind
  Thalia Zedek Band: Circa the End
  Thalia Zedek Band: Come Undone
  Thalia Zedek Band: Green and Blue
  Thalia Zedek Band: Stars

└→ $ ./lms help
Usage of /home/inigo/devel/go/src/lms/lms [options] command

  -h        Show help
  -imageviewer string
            Image viewer program to display cover (default "eog")
  -n        Use system notify to show result
  -player string
            Player to use (default "Squeezebox")
  -url string
            LMS URL and port (default "http://nas:9002")

Available commands: server, players, status, song, playlist, first, prev, next, power, pause, mute, volume [vol], cover, waybar, help

Note you can specify `-n` flag to display the output in the notification system instead of using the terminal.


Code is on this repository: https://hg.serna.eu/go/lms


Name:  ss-20200625_214255.jpg
Views: 131
Size:  107.9 KB

[*] Extract of my swaywm configuration, where I bind some keys to different LMS actions:
Code:

############################################################################
##### squeezebox
mode "squeezebox" {
        bindsym s                    exec /opt/emacs/bin/emacsclient -e "(lms-float)"; mode "default"
        bindsym h                    exec --no-startup-id curl 'http://nas:9002/settings/player/audio.html' --data-raw 'saveSettings=1&playerid=XXXX&pref_analogOutMode=2' -s >/dev/null; mode "default"
        bindsym Shift+h              exec --no-startup-id curl 'http://nas:9002/settings/player/audio.html' --data-raw 'saveSettings=1&playerid=XXXX&pref_analogOutMode=0' -s >/dev/null; mode "default"
        bindsym q                    exec --no-startup-id ~/bin/lms -n power; mode "default"
        bindsym a                    exec --no-startup-id ~/bin/lms -n status; mode "default"
        bindsym i                    exec --no-startup-id ~/bin/lms -n song; mode "default"
        bindsym c                    exec --no-startup-id ~/bin/lms cover; mode "default"
        bindsym l                    exec --no-startup-id ~/bin/lms -n playlist; mode "default"
        bindsym m                    exec --no-startup-id ~/bin/lms -n mute; mode "default"
        bindsym XF86AudioMute        exec --no-startup-id ~/bin/lms -n mute; mode "default"
        bindsym Down                exec --no-startup-id ~/bin/lms -n volume -5
        bindsym XF86AudioLowerVolume exec --no-startup-id ~/bin/lms -n volume -5
        bindsym Up                  exec --no-startup-id ~/bin/lms -n volume +5
        bindsym XF86AudioRaiseVolume exec --no-startup-id ~/bin/lms -n volume +5
        bindsym Home                exec --no-startup-id ~/bin/lms -n first; mode "default"
        bindsym XF86AudioPrev        exec --no-startup-id ~/bin/lms -n first; mode "default"
        bindsym Left                exec --no-startup-id ~/bin/lms -n prev; mode "default"
        bindsym XF86AudioRewind      exec --no-startup-id ~/bin/lms -n prev; mode "default"
        bindsym Right                exec --no-startup-id ~/bin/lms -n next; mode "default"
        bindsym XF86AudioForward    exec --no-startup-id ~/bin/lms -n next; mode "default"
        bindsym XF86AudioPlay        exec --no-startup-id ~/bin/lms -n pause; mode "default"
        bindsym space                exec --no-startup-id ~/bin/lms -n pause; mode "default"
        bindsym Return              mode "default"
        bindsym Escape              mode "default"
}
bindsym $mod+s mode "squeezebox"

Attached Images
 

Viewing all articles
Browse latest Browse all 2059

Trending Articles