Added a signal
Added the `player_stopped` signal to know when a player has ended.
This commit is contained in:
parent
8338c0100c
commit
352493f475
|
@ -7,6 +7,7 @@ This is a signal module in which you can connect to certain bling signals to gra
|
||||||
- If playing or not
|
- If playing or not
|
||||||
- Position
|
- Position
|
||||||
- Song length
|
- Song length
|
||||||
|
- If there are no players on
|
||||||
|
|
||||||
This module relies on `playerctl` and `curl`. If you have this module disabled, you won't need those programs. With this module, you can create a widget like below without worrying about the backend.
|
This module relies on `playerctl` and `curl`. If you have this module disabled, you won't need those programs. With this module, you can create a widget like below without worrying about the backend.
|
||||||
|
|
||||||
|
@ -30,6 +31,8 @@ Here are the signals available:
|
||||||
-- bling::playerctl::position
|
-- bling::playerctl::position
|
||||||
-- interval_sec (number)
|
-- interval_sec (number)
|
||||||
-- length_sec (number)
|
-- length_sec (number)
|
||||||
|
-- bling::playerctl::player_stopped
|
||||||
|
-- (No params)
|
||||||
```
|
```
|
||||||
|
|
||||||
### Example Implementation
|
### Example Implementation
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
--
|
||||||
-- Provides:
|
-- Provides:
|
||||||
-- bling::playerctl::status
|
-- bling::playerctl::status
|
||||||
-- playing (boolean)
|
-- playing (boolean)
|
||||||
|
@ -8,6 +9,7 @@
|
||||||
-- bling::playerctl::position
|
-- bling::playerctl::position
|
||||||
-- interval_sec (number)
|
-- interval_sec (number)
|
||||||
-- length_sec (number)
|
-- length_sec (number)
|
||||||
|
-- bling::playerctl::player_stopped
|
||||||
--
|
--
|
||||||
local awful = require("awful")
|
local awful = require("awful")
|
||||||
local beautiful = require("beautiful")
|
local beautiful = require("beautiful")
|
||||||
|
@ -92,10 +94,14 @@ echo "$tmp_cover_path"
|
||||||
-- Get title and artist
|
-- Get title and artist
|
||||||
local artist = line:match('artist_(.*)title_')
|
local artist = line:match('artist_(.*)title_')
|
||||||
local title = line:match('title_(.*)')
|
local title = line:match('title_(.*)')
|
||||||
|
-- If the title is nil or empty then the players stopped
|
||||||
if title and title ~= "" then
|
if title and title ~= "" then
|
||||||
awesome.emit_signal(
|
awesome.emit_signal(
|
||||||
"bling::playerctl::title_artist_album", title,
|
"bling::playerctl::title_artist_album", title,
|
||||||
artist, album_path)
|
artist, album_path)
|
||||||
|
else
|
||||||
|
awesome.emit_signal(
|
||||||
|
"bling::playerctl::player_stopped")
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue