Code Monkey home page Code Monkey logo

Comments (1)

akemrir avatar akemrir commented on August 20, 2024

I figured it out

local GET_MPD_CMD = "mpc -p 7600 status"
local TOGGLE_MPD_CMD = "mpc -p 7600 toggle"

local mpd_status = function()
  local ret = {}
  ret.text = 'Loading'
  ret.alert = false
  ret.value = 0.5

	local line = redutil.read.output(GET_MPD_CMD)
  local stdout = string.gsub(line, "\n", "")
  local mpdpercent = string.match(stdout, "(%d+)%%")

  if string.match(stdout, "%[playing]") then
    local value = tonumber(mpdpercent/100)
    ret.value = value
    ret.text = 'MPD: '.. mpdpercent .. '% utworu'
  elseif string.match(stdout, "%[paused]") then
    local value = tonumber(mpdpercent/100)
    ret.value = value
    ret.text = 'MPD: '..mpdpercent .. '% utworu'
    ret.alert = true
  elseif string.match(stdout, "MPD error") then
    ret.value = 1
    ret.text = "MPD: niepodłączone"
    ret.alert = false
  else
    ret.value = 1
    ret.text = "Sprawdź rc-orange.lua +261"
    ret.alert = true
  end

  return ret
end

sysmon.widget.mpd = redflat.widget.sysmon(
  { func = mpd_status },
	{ timeout = 1, widget = redflat.gauge.monitor.circle }
)
sysmon.buttons.mpd = awful.util.table.join(
	awful.button({ }, 1, function() awful.spawn(TOGGLE_MPD_CMD) end)
)

from redflat.

Related Issues (20)

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.