Spotify widget can only pause spotify

This commit is contained in:
Gürkan 2024-06-07 10:46:48 +02:00
parent e3b713f742
commit 5e5adc098d
2 changed files with 30 additions and 9 deletions

View File

@ -125,8 +125,9 @@ triggerwibox = function(action)
slider_timer:again()
end
function fn_process_action(action, direction)
function fn_process_action(action, direction, player)
direction = direction or 'toggle'
player = player or nil
-- Case 1: Sound mute toggle
if action == 'sink' then
@ -193,18 +194,38 @@ function fn_process_action(action, direction)
elseif action == 'media' then
show_osd = false
if direction == 'pausetoggle' then
helpers.async('playerctl play-pause', function(out) end)
if player ~= nil then
helpers.async('playerctl play-pause -p ' .. player, function(out) end)
else
helpers.async('playerctl play-pause', function(out) end)
end
show_osd = true
elseif direction == 'stop' then
helpers.async('playerctl stop', function(out) end)
if player ~= nil then
helpers.async('playerctl stop -p ' .. player, function(out) end)
else
helpers.async('playerctl stop', function(out) end)
end
show_osd = true
elseif direction == 'next' then
helpers.async('playerctl next', function(out) end)
if player ~= nil then
helpers.async('playerctl next -p ' .. player, function(out) end)
else
helpers.async('playerctl next', function(out) end)
end
elseif direction == 'previous' then
helpers.async('playerctl previous', function(out) end)
if player ~= nil then
helpers.async('playerctl previous -p ' .. player, function(out) end)
else
helpers.async('playerctl previous', function(out) end)
end
end
if show_osd then
helpers.async('playerctl status', function(out) triggerwibox(out) end, 0.3)
if player ~= nil then
helpers.async('playerctl status -p ' .. player, function(out) triggerwibox(out) end, 0.3)
else
helpers.async('playerctl status', function(out) triggerwibox(out) end, 0.3)
end
end
end
end

6
rc.lua
View File

@ -384,18 +384,18 @@ end)))
-- ))
spotify:buttons(awful.util.table.join(
awful.button({}, 1, function() -- left click
fn_process_action('media', 'pausetoggle')
fn_process_action('media', 'pausetoggle', 'spotify')
spotify:check()
end),
awful.button({}, 3, function() -- right click
spotify:raise_toggle()
end),
awful.button({}, 4, function() -- scroll up
fn_process_action('media', 'previous')
fn_process_action('media', 'previous', 'spotify')
spotify:check()
end),
awful.button({}, 5, function() -- scroll down
fn_process_action('media', 'next')
fn_process_action('media', 'next', 'spotify')
spotify:check()
end)
))