Code Monkey home page Code Monkey logo

mpd_queue_stats's Introduction

mpd_queue_stats

This program, written in Rust, returns a string for use by Conky. The string is in the following format:

"{}${{alignc}}{}${{alignr}}${{offset -5}}{}\n$alignc${{voffset -40}}${{offset 30}}{:.2}%"

...where each {} is replaced by the following values in this order:

1. Elapsed time
2. Total length of the queue
3. Remaining time
4. Percent elapsed

Note that all values relate to the queue, not the currently playing song, although the 'Elapsed time' also includes the elapsed time of the current song.

In conky, this is invoked this way:

${execpi n (mpd_queue_stats)}

...where n is an integer defining how often conky calls this function. Note that either mpd_queue_stats must be on the $PATH available to Conky when it is run, or you must include a complete path to the mpd_queue_stats executable. e.g.

${execpi n (/home/username/mybin/mpd_queue_stats)}

Note there is a line-break, and then the string sends the cursor to the middle of the line and then adds an offset of 50 pixels before outputting the percent. This is what I needed for my conky setup. If your needs differ, adjust the output string to suit you. My .conkymusic file sets the window to 280 pixels wide.

Building

If you are unfamiliar with Rust, the folder mpd_queue_stats is the root of the crate. A crate describes a project and its dependencies. The actual code is located in the mpd_queue_stats/src folder, and is named mpd_queue_stats.rs. In this file is a constant which needs changing if your MPD is not running on the same machine as your instance of Conky, or uses a different port. The line looks like this:

const HOST: &str = "localhost:6600";

Assuming you have installed Rust, then from the root of the mpd_queue_stats folder:

$ cargo ret

If everything goes well:

$ cargo build --release

The executable will be found as mpd_queue_stats/target/release/mpd_queue_stats.

See Also

  1. mpd_queue_len
  2. mpd_queue_stats
  3. mpd_percent

mpd_queue_stats's People

Contributors

stroggprog avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.