summaryrefslogtreecommitdiffstats
path: root/modules/desktop/awesome/widgets
diff options
context:
space:
mode:
Diffstat (limited to 'modules/desktop/awesome/widgets')
-rw-r--r--modules/desktop/awesome/widgets/calendar.lua115
-rw-r--r--modules/desktop/awesome/widgets/mpd.lua86
-rw-r--r--modules/desktop/awesome/widgets/volume.lua60
3 files changed, 0 insertions, 261 deletions
diff --git a/modules/desktop/awesome/widgets/calendar.lua b/modules/desktop/awesome/widgets/calendar.lua
deleted file mode 100644
index 6e791b3..0000000
--- a/modules/desktop/awesome/widgets/calendar.lua
+++ /dev/null
@@ -1,115 +0,0 @@
-local awful = require("awful")
-local beautiful = require("beautiful")
-local wibox = require("wibox")
-local gears = require("gears")
-
-local calendar_widget = {}
-
-local function worker(user_args)
- local args = user_args or {}
-
- local style = {}
-
- style.month = {
- padding = 4,
- bg_color = beautiful.bg_normal,
- border_width = 0
- }
-
- style.normal = {
- markup = function(t) return t end,
- shape = function(cr, width, height) gears.shape.rounded_rect(cr, width, height, 4) end,
- }
-
- style.focused = {
- bg_color = beautiful.bg_focus,
- fg_color = beautiful.fg_focus,
- markup = function(t) return '<b>' .. t .. '</b>' end,
- shape = function(cr, width, height) gears.shape.rounded_rect(cr, width, height, 4) end,
- }
-
- style.header = {
- bg_color = beautiful.bg_focus,
- fg_color = beautiful.fg_focus,
- markup = function(t) return '<b>'..t..'</b>' end,
- }
-
- style.weekday = {
- bg_color = beautiful.bg_focus,
- fg_color = beautiful.fg_focus,
- markup = function(t) return '<b>'..t..'</b>' end,
- }
-
- local function decorate(widget, flag, date)
- if flag == 'monthheader' then flag = 'header' end
- if flag == 'focus' then
- local today = os.date('*t')
- if not today.month == date.month and today.year == date.year then
- flag = 'normal'
- end
- end
- local properties = style[flag] or {}
- if properties.markup and widget.get_text and widget.set_markup then
- widget:set_markup(properties.markup(widget:get_text()))
- end
- local thisdate = { year = date.year, month = (date.month or 1), day = (date.day or 1) }
- local weekday = tonumber(os.date('%w', os.time(d)))
- local default_bg = (weekday == 0 or weekday == 6)
- and beautiful.bg_focused
- or beautiful.bg_normal
- return wibox.widget {
- {
- {
- widget,
- halign = 'center',
- widget = wibox.container.place
- },
- margins = (properties.padding or 2) + (properties.border_width or 0),
- widget = wibox.container.margin
- },
- shape = properties.shape,
- shape_border_color = properties.border_color or '#00000000',
- shape_border_width = properties.border_width or 0,
- fg = properties.fg_color or beautiful.fg_normal,
- bg = properties.bg_color or beautiful.bg_normal,
- widget = wibox.container.background
- }
- end
-
- local cal = wibox.widget {
- date = os.date('*t'),
- font = beautiful.get_font(),
- fn_embed = decorate,
- long_weekdays = true,
- start_sunday = true,
- widget = wibox.widget.calendar.month
- }
-
- local popup = awful.popup {
- ontop = true,
- visible = false,
- shape = gears.shape.rounded_rect,
- offset = { y = 5 },
- border_width = 2,
- border_color = beautiful.fg_minimize,
- widget = cal
- }
-
- function calendar_widget.toggle()
- if popup.visible then
- cal:set_date(nil)
- cal:set_date(os.date('*t'))
- popup:set_widget(nil)
- popup:set_widget(cal)
- popup.visible = not popup.visible
- else
- awful.placement.top_right(popup, { margins = { top = 30, right = 10 }, parent = awful.screen.focused() })
- popup.visible = true
- end
- end
- return calendar_widget
-end
-
-return setmetatable(calendar_widget, { __call = function(_, ...)
- return worker(...)
-end})
diff --git a/modules/desktop/awesome/widgets/mpd.lua b/modules/desktop/awesome/widgets/mpd.lua
deleted file mode 100644
index d588089..0000000
--- a/modules/desktop/awesome/widgets/mpd.lua
+++ /dev/null
@@ -1,86 +0,0 @@
-local awful = require("awful")
-local spawn = require("awful.spawn")
-local watch = require("awful.widget.watch")
-local beautiful = require("beautiful")
-local wibox = require("wibox")
-local gears = require("gears")
-local naughty = require("naughty")
-
-local mpd_widget = {}
-
-local MUSIC_ICON = ' '
-local OFF_ICON = '󰝛 '
-
-local PLAY_ICON = ' '
-local PAUSE_ICON = ' '
-
-local PREV_ICON = ' '
-local NEXT_ICON = ' '
-
-local function worker(user_args)
- local mpd_bar = wibox.widget {
- {
- id = "progress",
- widget = wibox.widget.progressbar,
- max_value = 1,
- forced_height = 12,
- forced_width = 150,
- border_width = 0,
- color = beautiful.bg_focus,
- background_color = beautiful.bg_normal,
- },
- {
- id = "title",
- widget = wibox.widget.textbox,
- text = "NO SONG",
- valign = "center",
- halign = "center",
- },
- layout = wibox.layout.stack
- }
-
- local status_icon = wibox.widget {
- id = "status",
- widget = wibox.widget.textbox,
- text = PLAY_ICON
- }
-
- local update = function(widget, stdout, _, _, _)
- local current_song = string.gmatch(stdout, "[^\r\n]+")()
- stdout = string.gsub(stdout, "\n", "")
- local mpd_percent = string.match(stdout, "(%d%d)%%")
- local mpd_status = string.match(stdout, "%[(%a+)%]")
-
- widget:get_children_by_id("title")[1].text = current_song
- widget:get_children_by_id("progress")[1].value = tonumber(mpd_percent)/100
-
- if mpd_status == "playing" then
- status_icon.text = PLAY_ICON
- elseif mpd_status == "paused" then
- status_icon.text = PAUSE_ICON
- end
- end
-
- mpd_bar:connect_signal("button::press", function(_, _, _, button)
- if button == 1 then awful.spawn("mpc toggle", false)
- elseif button == 3 then awful.spawn("kitty -e ncmpcpp", false)
- elseif button == 4 then awful.spawn("mpc next", false)
- elseif button == 5 then awful.spawn("mpc prev", false)
- end
- end)
-
- watch("mpc status", 1, update, mpd_bar)
-
- mpd_widget = wibox.widget {
- status_icon,
- mpd_bar,
- layout = wibox.layout.align.horizontal,
- spacing = 8,
- }
-
- return mpd_widget
-end
-
-return setmetatable(mpd_widget, { __call = function(_, ...)
- return worker(...)
-end})
diff --git a/modules/desktop/awesome/widgets/volume.lua b/modules/desktop/awesome/widgets/volume.lua
deleted file mode 100644
index 21c200b..0000000
--- a/modules/desktop/awesome/widgets/volume.lua
+++ /dev/null
@@ -1,60 +0,0 @@
-local awful = require("awful")
-local spawn = require("awful.spawn")
-local watch = require("awful.widget.watch")
-local beautiful = require("beautiful")
-local wibox = require("wibox")
-local gears = require("gears")
-local naughty = require("naughty")
-
-local volume_widget = {}
-
-local get_volume_cmd = "bash -c 'wpctl get-volume @DEFAULT_AUDIO_SINK@'"
-
-local function worker(user_args)
- local volume_bar = wibox.widget {
- bar_shape = gears.shape.rounded_rect,
- bar_height = 4,
- bar_color = beautiful.fg_focus,
- handle_color = beautiful.fg_focus,
- handle_shape = gears.shape.circle,
- handle_border_width = 0,
- value = 0,
- forced_width = 50,
- widget = wibox.widget.slider,
- }
-
- volume_widget = wibox.widget {
- {
- layout = wibox.layout.fixed.horizontal,
- {
- text = "󰕾 ",
- widget = wibox.widget.textbox
- },
- volume_bar,
- spacing = 4
- },
- widget = wibox.container.margin,
- left = 8,
- }
-
- local function percentage(value)
- return math.floor(value)
- end
-
- watch(get_volume_cmd, 1,
- function(widget, stdout)
- volume = stdout:match('0.%d+')
- widget.value = tonumber(volume) * 100
- end, volume_bar)
-
- volume_bar:connect_signal("property::value",
- function(self)
- spawn.easy_async("bash -c 'wpctl set-volume @DEFAULT_AUDIO_SINK@ " .. self.value .. "%'", function() end)
- end)
-
- return volume_widget
-end
-
-return setmetatable(volume_widget, { __call = function(_, ...)
- return worker(...)
-end})