summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--calendar-widget/README.md21
-rw-r--r--calendar-widget/calendar.lua7
-rw-r--r--mpris-widget/init.lua113
3 files changed, 40 insertions, 101 deletions
diff --git a/calendar-widget/README.md b/calendar-widget/README.md
index 3d878bf..c7b46e2 100644
--- a/calendar-widget/README.md
+++ b/calendar-widget/README.md
@@ -4,7 +4,6 @@ Calendar widget for Awesome WM - slightly improved version of the `wibox.widget.
## Features
- - mouse support: scroll up - shows next month, scroll down - previous
- themes:
| Name | Screenshot |
@@ -30,6 +29,23 @@ Calendar widget for Awesome WM - slightly improved version of the `wibox.widget.
![calendar_bottom_right](./calendar_bottom_right.png)
+ - mouse support:
+ move to the next and previous month. Using mouse buttons or scroll wheel.
+
+ You can configure this by specifying the button to move to next/previous.
+ Usually these are configured as follows. If you want to use other mouse buttons, you can find their number using `xev`.
+
+ | number | button |
+ |--------|--------|
+ | 4 | scroll up |
+ | 5 | scroll down |
+ | 1 | left click |
+ | 2 | right click |
+ | 3 | middles click |
+
+ By default `previous_month_button` is 5, `next_month_button` is 4.
+
+
## How to use
This widget needs an 'anchor' - another widget which triggers visibility of the calendar. Default `mytextclock` is the perfect candidate!
@@ -47,6 +63,9 @@ local cw = calendar_widget({
theme = 'outrun',
placement = 'bottom_right',
radius = 8,
+-- with customized next/previous (see table above)
+ previous_month_button = 1,
+ next_month_button = 3,
})
mytextclock:connect_signal("button::press",
function(_, _, _, button)
diff --git a/calendar-widget/calendar.lua b/calendar-widget/calendar.lua
index 81c28a9..d62f52b 100644
--- a/calendar-widget/calendar.lua
+++ b/calendar-widget/calendar.lua
@@ -95,7 +95,8 @@ local function worker(user_args)
local theme = args.theme or 'naughty'
local placement = args.placement or 'top'
local radius = args.radius or 8
-
+ local next_month_button = args.next_month_button or 4
+ local previous_month_button = args.previous_month_button or 5
local styles = {}
local function rounded_shape(size)
@@ -198,14 +199,14 @@ local function worker(user_args)
popup:buttons(
awful.util.table.join(
- awful.button({}, 4, function()
+ awful.button({}, next_month_button, function()
local a = cal:get_date()
a.month = a.month + 1
cal:set_date(nil)
cal:set_date(a)
popup:set_widget(cal)
end),
- awful.button({}, 5, function()
+ awful.button({}, previous_month_button, function()
local a = cal:get_date()
a.month = a.month - 1
cal:set_date(nil)
diff --git a/mpris-widget/init.lua b/mpris-widget/init.lua
index 7669b10..5e45ffa 100644
--- a/mpris-widget/init.lua
+++ b/mpris-widget/init.lua
@@ -7,17 +7,13 @@
-------------------------------------------------
local awful = require("awful")
local beautiful = require("beautiful")
-local spawn = require("awful.spawn")
local watch = require("awful.widget.watch")
local wibox = require("wibox")
-local naughty = require("naughty")
local gears = require("gears")
-local GET_MPD_CMD = "playerctl -p %s -f '{{status}};{{xesam:artist}};{{xesam:title}};{{mpris:artUrl}}' metadata"
+local GET_MPD_CMD = "playerctl -p %s -f '{{status}};{{xesam:artist}};{{xesam:title}}' metadata"
local TOGGLE_MPD_CMD = "playerctl play-pause"
-local PAUSE_MPD_CMD = "playerctl pause"
-local STOP_MPD_CMD = "playerctl stop"
local NEXT_MPD_CMD = "playerctl next"
local PREV_MPD_CMD = "playerctl previous"
local LIST_PLAYERS_CMD = "playerctl -l"
@@ -30,12 +26,19 @@ local LIBRARY_ICON_NAME = PATH_TO_ICONS .. "/actions/24/music-library.png"
local default_player = ''
+local icon = wibox.widget {
+ id = "icon",
+ widget = wibox.widget.imagebox,
+ image = PLAY_ICON_NAME
+}
+
local mpris_widget = wibox.widget{
{
id = 'artist',
widget = wibox.widget.textbox
},
{
+ icon,
max_value = 1,
value = 0,
thickness = 2,
@@ -74,9 +77,9 @@ local popup = awful.popup{
local function rebuild_popup()
awful.spawn.easy_async(LIST_PLAYERS_CMD, function(stdout, _, _, _)
+ for i = 0, #rows do rows[i]=nil end
for player_name in stdout:gmatch("[^\r\n]+") do
- if player_name ~='' or player_name ~=nil then
- for i = 0, #rows do rows[i]=nil end
+ if player_name ~='' and player_name ~=nil then
local checkbox = wibox.widget{
{
@@ -130,96 +133,35 @@ end
local function worker()
-- retrieve song info
- local current_song, artist, mpdstatus, art, artUrl
-
- local icon = wibox.widget {
- id = "icon",
- widget = wibox.widget.imagebox,
- image = PLAY_ICON_NAME
- }
- local mirrored_icon = wibox.container.mirror(icon, {horizontal = true})
-
- local mpdarc = wibox.widget {
- mirrored_icon,
- -- max_value = 1,
- -- value = 0,
- thickness = 2,
- start_angle = 4.71238898, -- 2pi*3/4
- forced_height = 24,
- forced_width = 24,
- rounded_edge = true,
- bg = "#ffffff11",
- paddings = 0,
- widget = wibox.container.arcchart
- }
-
- local mpdarc_icon_widget = wibox.container.mirror(mpdarc, {horizontal = true})
- local mpdarc_current_song_widget = wibox.widget {
- id = 'current_song',
- widget = wibox.widget.textbox,
- font = 'Play 10'
- }
+ local current_song, artist, player_status
local update_graphic = function(widget, stdout, _, _, _)
- -- mpdstatus, artist, current_song = stdout:match("(%w+)%;+(.-)%;(.*)")
- local words = {}
- for w in stdout:gmatch("([^;]*);") do table.insert(words, w) end
-
- mpdstatus = words[1]
+ local words = gears.string.split(stdout, ';')
+ player_status = words[1]
artist = words[2]
current_song = words[3]
- art = words[4]
if current_song ~= nil then
if string.len(current_song) > 18 then
current_song = string.sub(current_song, 0, 9) .. ".."
end
end
- if art ~= nil then artUrl = string.sub(art, 8, -1) end
-
- if mpdstatus == "Playing" then
- mpdarc_icon_widget.visible = true
+ if player_status == "Playing" then
icon.image = PLAY_ICON_NAME
widget.colors = {beautiful.widget_main_color}
- mpdarc_current_song_widget.markup = current_song
widget:set_text(artist, current_song)
- elseif mpdstatus == "Paused" then
- mpdarc_icon_widget.visible = true
+ elseif player_status == "Paused" then
icon.image = PAUSE_ICON_NAME
widget.colors = {beautiful.widget_main_color}
- mpdarc_current_song_widget.markup = current_song
widget:set_text(artist, current_song)
- elseif mpdstatus == "Stopped" then
- mpdarc_icon_widget.visible = true
+ elseif player_status == "Stopped" then
icon.image = STOP_ICON_NAME
- mpdarc_current_song_widget.markup = ""
else -- no player is running
icon.image = LIBRARY_ICON_NAME
- mpdarc_icon_widget.visible = false
- mpdarc_current_song_widget.markup = ""
widget.colors = {beautiful.widget_red}
end
end
- mpdarc:connect_signal("button::press", function(_, _, _, button)
- if (button == 1) then
- awful.spawn(TOGGLE_MPD_CMD, false) -- left click
- elseif (button == 2) then
- awful.spawn(STOP_MPD_CMD, false)
- elseif (button == 3) then
- awful.spawn(PAUSE_MPD_CMD, false)
- elseif (button == 4) then
- awful.spawn(NEXT_MPD_CMD, false) -- scroll up
- elseif (button == 5) then
- awful.spawn(PREV_MPD_CMD, false) -- scroll down
- end
-
- -- spawn.easy_async(string.format(GET_MPD_CMD, "'" .. default_player .. "'"),
- -- function(stdout, stderr, exitreason, exitcode)
- -- update_graphic(mpdarc, stdout, stderr, exitreason, exitcode)
- -- end)
- end)
-
mpris_widget:buttons(
awful.util.table.join(
awful.button({}, 3, function()
@@ -236,29 +178,6 @@ local function worker()
)
)
-
-
- local notification
- local function show_MPD_status()
- spawn.easy_async(GET_MPD_CMD, function()
- notification = naughty.notification {
- margin = 10,
- timeout = 5,
- hover_timeout = 0.5,
- width = 240,
- height = 90,
- title = "<b>" .. mpdstatus .. "</b>",
- text = current_song .. " <b>by</b> " .. artist,
- image = artUrl
- }
- end)
- end
-
- mpdarc:connect_signal("mouse::enter", function()
- if current_song ~= nil and artist ~= nil then show_MPD_status() end
- end)
- mpdarc:connect_signal("mouse::leave", function() naughty.destroy(notification) end)
-
watch(string.format(GET_MPD_CMD, "'" .. default_player .. "'"), 1, update_graphic, mpris_widget)
return mpris_widget