summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md2
-rw-r--r--battery-widget/battery.lua30
-rw-r--r--batteryarc-widget/README.md2
-rw-r--r--batteryarc-widget/batteryarc.lua30
-rw-r--r--cpu-widget/cpu-widget.lua2
-rw-r--r--mpdarc-widget/README.md14
-rw-r--r--mpdarc-widget/mpdarc.lua100
-rw-r--r--ram-widget/ram-widget.lua20
-rw-r--r--translate-widget/translate.lua14
9 files changed, 195 insertions, 19 deletions
diff --git a/README.md b/README.md
index eb98f06..f7f8b97 100644
--- a/README.md
+++ b/README.md
@@ -8,6 +8,8 @@ or with separators
![screenshot](./screenshot_with_sprtrs.png)
+Some more screenshots in this reddit [post](https://www.reddit.com/r/unixporn/comments/8qijmx/awesomewm_dark_theme/)
+
From left to right:
- [spotify-widget](https://github.com/streetturtle/AwesomeWM/tree/master/spotify-widget) / [rhythmbox-widget](https://github.com/streetturtle/AwesomeWM/tree/master/rhythmbox-widget)
diff --git a/battery-widget/battery.lua b/battery-widget/battery.lua
index 01a3ddd..4cbc314 100644
--- a/battery-widget/battery.lua
+++ b/battery-widget/battery.lua
@@ -67,14 +67,36 @@ local function show_battery_warning()
}
end
+local last_battery_check = os.time()
+
watch("acpi", 10,
function(widget, stdout, stderr, exitreason, exitcode)
local batteryType
- local _, status, charge_str, time = string.match(stdout, '(.+): (%a+), (%d?%d?%d)%%,? ?.*')
- local charge = tonumber(charge_str)
+
+ local battery_info = {}
+ for s in stdout:gmatch("[^\r\n]+") do
+ local _, status, charge_str, time = string.match(s, '(.+): (%a+), (%d?%d?%d)%%,? ?.*')
+ table.insert(battery_info, {status = status, charge = tonumber(charge_str)})
+ end
+
+ local charge = 0
+ local status
+ for i, batt in ipairs(battery_info) do
+ if batt.charge >= charge then
+ status = batt.status -- use most charged battery status
+ -- this is arbitrary, and maybe another metric should be used
+ end
+
+ charge = charge + batt.charge
+ end
+ charge = charge // #battery_info -- use average charge for battery icon
+
if (charge >= 0 and charge < 15) then
batteryType = "battery-empty%s-symbolic"
- if status ~= 'Charging' then
+ if status ~= 'Charging' and os.difftime(os.time(), last_battery_check) > 300 then
+ -- if 5 minutes have elapsed since the last warning
+ last_battery_check = time()
+
show_battery_warning()
end
elseif (charge >= 15 and charge < 40) then batteryType = "battery-caution%s-symbolic"
@@ -82,11 +104,13 @@ watch("acpi", 10,
elseif (charge >= 60 and charge < 80) then batteryType = "battery-good%s-symbolic"
elseif (charge >= 80 and charge <= 100) then batteryType = "battery-full%s-symbolic"
end
+
if status == 'Charging' then
batteryType = string.format(batteryType, '-charging')
else
batteryType = string.format(batteryType, '')
end
+
widget.icon:set_image(PATH_TO_ICONS .. batteryType .. ".svg")
-- Update popup text
diff --git a/batteryarc-widget/README.md b/batteryarc-widget/README.md
index 6a451d1..cb73e09 100644
--- a/batteryarc-widget/README.md
+++ b/batteryarc-widget/README.md
@@ -29,7 +29,7 @@ which means that you need to copy the code above and paste it in your **theme.lu
Clone repo, include widget and use it in **rc.lua**:
```lua
-require("volumearc")
+local batteryarc_widget = require("awesome-wm-widgets.batteryarc-widget.batteryarc")
...
s.mytasklist, -- Middle widget
{ -- Right widgets
diff --git a/batteryarc-widget/batteryarc.lua b/batteryarc-widget/batteryarc.lua
index e1ab203..48233f3 100644
--- a/batteryarc-widget/batteryarc.lua
+++ b/batteryarc-widget/batteryarc.lua
@@ -38,11 +38,30 @@ local batteryarc = wibox.widget {
-- mirror the widget, so that chart value increases clockwise
local batteryarc_widget = wibox.container.mirror(batteryarc, { horizontal = true })
+local last_battery_check = os.time()
+
watch("acpi", 10,
function(widget, stdout, stderr, exitreason, exitcode)
local batteryType
- local _, status, charge_str, time = string.match(stdout, '(.+): (%a+), (%d?%d%d)%%,? ?.*')
- local charge = tonumber(charge_str)
+
+ local battery_info = {}
+ for s in stdout:gmatch("[^\r\n]+") do
+ local _, status, charge_str, time = string.match(s, '(.+): (%a+), (%d?%d?%d)%%,? ?.*')
+ table.insert(battery_info, {status = status, charge = tonumber(charge_str)})
+ end
+
+ local charge = 0
+ local status
+ for i, batt in ipairs(battery_info) do
+ if batt.charge >= charge then
+ status = batt.status -- use most charged battery status
+ -- this is arbitrary, and maybe another metric should be used
+ end
+
+ charge = charge + batt.charge
+ end
+ charge = charge // #battery_info -- use average charge for battery icon
+
widget.value = charge / 100
if status == 'Charging' then
mirrored_text_with_background.bg = beautiful.widget_green
@@ -54,7 +73,10 @@ watch("acpi", 10,
if charge < 15 then
batteryarc.colors = { beautiful.widget_red }
- if status ~= 'Charging' then
+ if status ~= 'Charging' and os.difftime(os.time(), last_battery_check) > 300 then
+ -- if 5 minutes have elapsed since the last warning
+ last_battery_check = time()
+
show_battery_warning()
end
elseif charge > 15 and charge < 40 then
@@ -110,4 +132,4 @@ function show_battery_warning()
}
end
-return batteryarc_widget \ No newline at end of file
+return batteryarc_widget
diff --git a/cpu-widget/cpu-widget.lua b/cpu-widget/cpu-widget.lua
index f7fc2e4..f466d09 100644
--- a/cpu-widget/cpu-widget.lua
+++ b/cpu-widget/cpu-widget.lua
@@ -27,7 +27,7 @@ local cpu_widget = wibox.container.margin(wibox.container.mirror(cpugraph_widget
local total_prev = 0
local idle_prev = 0
-watch("cat /proc/stat | grep '^cpu '", 1,
+watch([[bash -c "cat /proc/stat | grep '^cpu '"]], 1,
function(widget, stdout, stderr, exitreason, exitcode)
local user, nice, system, idle, iowait, irq, softirq, steal, guest, guest_nice =
stdout:match('(%d+)%s(%d+)%s(%d+)%s(%d+)%s(%d+)%s(%d+)%s(%d+)%s(%d+)%s(%d+)%s(%d+)%s')
diff --git a/mpdarc-widget/README.md b/mpdarc-widget/README.md
new file mode 100644
index 0000000..0a6ffa6
--- /dev/null
+++ b/mpdarc-widget/README.md
@@ -0,0 +1,14 @@
+# MPD Widget
+
+Music Player Daemon widget by @raphaelfournier.
+
+# Prerequisite
+
+Install `mpd` (Music Player Daemon itself) and `mpc` (Music Player Client - program for controlling mpd), both should be available in repo, e.g for Ubuntu:
+
+```bash
+sudo apt-get install mpd mpc
+```
+
+Set them up and then just follow the [installation](https://github.com/streetturtle/awesome-wm-widgets#installation) section of the repo.
+
diff --git a/mpdarc-widget/mpdarc.lua b/mpdarc-widget/mpdarc.lua
new file mode 100644
index 0000000..56009ef
--- /dev/null
+++ b/mpdarc-widget/mpdarc.lua
@@ -0,0 +1,100 @@
+-------------------------------------------------
+-- mpd Arc Widget for Awesome Window Manager
+-- Modelled after Pavel Makhov's work
+
+-- @author Raphaël Fournier-S'niehotta
+-- @copyright 2018 Raphaël Fournier-S'niehotta
+-------------------------------------------------
+
+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 GET_MPD_CMD = "mpc status"
+local PAUSE_MPD_CMD = "mpc pause"
+local STOP_MPD_CMD = "mpc stop"
+local NEXT_MPD_CMD = "mpc next"
+local PREV_MPD_CMD = "mpc prev"
+
+local PATH_TO_ICONS = "/usr/share/icons/Arc"
+local PAUSE_ICON_NAME = PATH_TO_ICONS .. "/actions/24/player_pause.png"
+local PLAY_ICON_NAME = PATH_TO_ICONS .. "/actions/24/player_play.png"
+local STOP_ICON_NAME = PATH_TO_ICONS .. "/actions/24/player_stop.png"
+
+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.75,
+ thickness = 2,
+ start_angle = 4.71238898, -- 2pi*3/4
+ forced_height = 32,
+ forced_width = 32,
+ rounded_edge = true,
+ bg = "#ffffff11",
+ paddings = 0,
+ widget = wibox.container.arcchart
+}
+
+local mpdarc_widget = wibox.container.mirror(mpdarc, { horizontal = true })
+
+local update_graphic = function(widget, stdout, _, _, _)
+ stdout = string.gsub(stdout, "\n", "")
+ local mpdpercent = string.match(stdout, "(%d%d)%%")
+ local mpdstatus = string.match(stdout, "%[(%a+)%]")
+ if mpdstatus == "playing" then
+ icon.image = PLAY_ICON_NAME
+ widget.colors = { beautiful.widget_main_color }
+ widget.value = tonumber((100-mpdpercent)/100)
+ elseif mpdstatus == "paused" then
+ icon.image = PAUSE_ICON_NAME
+ widget.colors = { beautiful.widget_main_color }
+ widget.value = tonumber(mpdpercent/100)
+ else
+ icon.image = STOP_ICON_NAME
+ widget.colors = { beautiful.widget_red }
+ end
+end
+
+mpdarc:connect_signal("button::press", function(_, _, _, button)
+ if (button == 1) then awful.spawn("mpc toggle", 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(GET_MPD_CMD, function(stdout, stderr, exitreason, exitcode)
+ update_graphic(mpdarc, stdout, stderr, exitreason, exitcode)
+ end)
+end)
+
+local notification
+function show_MPD_status()
+ spawn.easy_async(GET_MPD_CMD,
+ function(stdout, _, _, _)
+ notification = naughty.notify {
+ text = stdout,
+ title = "MPD",
+ timeout = 5,
+ hover_timeout = 0.5,
+ width = 600,
+ }
+ end)
+end
+
+mpdarc:connect_signal("mouse::enter", function() show_MPD_status() end)
+mpdarc:connect_signal("mouse::leave", function() naughty.destroy(notification) end)
+
+watch(GET_MPD_CMD, 1, update_graphic, mpdarc)
+
+return mpdarc_widget
diff --git a/ram-widget/ram-widget.lua b/ram-widget/ram-widget.lua
index b378990..d352bd7 100644
--- a/ram-widget/ram-widget.lua
+++ b/ram-widget/ram-widget.lua
@@ -37,21 +37,23 @@ w:setup {
widget = wibox.widget.piechart
}
-local total, used, free, shared, buff_cache, available
+local total, used, free, shared, buff_cache, available, total_swap, used_swap, free_swap
local function getPercentage(value)
- return math.floor(value / total * 100 + 0.5) .. '%'
+ return math.floor(value / (total+total_swap) * 100 + 0.5) .. '%'
end
-watch('bash -c "free | grep Mem"', 1,
+watch('bash -c "free | grep -z Mem.*Swap.*"', 1,
function(widget, stdout, stderr, exitreason, exitcode)
- total, used, free, shared, buff_cache, available = stdout:match('(%d+)%s*(%d+)%s*(%d+)%s*(%d+)%s*(%d+)%s*(%d+)')
- widget.data = { used, total-used }
+ total, used, free, shared, buff_cache, available, total_swap, used_swap, free_swap =
+ stdout:match('(%d+)%s*(%d+)%s*(%d+)%s*(%d+)%s*(%d+)%s*(%d+)%s*Swap:%s*(%d+)%s*(%d+)%s*(%d+)')
+
+ widget.data = { used, total-used } widget.data = { used, total-used }
if w.visible then
w.pie.data_list = {
- {'used ' .. getPercentage(used), used},
- {'free ' .. getPercentage(free), free},
+ {'used ' .. getPercentage(used + used_swap), used + used_swap},
+ {'free ' .. getPercentage(free + free_swap), free + free_swap},
{'buff_cache ' .. getPercentage(buff_cache), buff_cache}
}
end
@@ -64,8 +66,8 @@ ramgraph_widget:buttons(
awful.button({}, 1, function()
awful.placement.top_right(w, { margins = {top = 25, right = 10}})
w.pie.data_list = {
- {'used ' .. getPercentage(used), used},
- {'free ' .. getPercentage(free), free},
+ {'used ' .. getPercentage(used + used_swap), used + used_swap},
+ {'free ' .. getPercentage(free + free_swap), free + free_swap},
{'buff_cache ' .. getPercentage(buff_cache), buff_cache}
}
w.pie.display_labels = true
diff --git a/translate-widget/translate.lua b/translate-widget/translate.lua
index b1944dc..e046604 100644
--- a/translate-widget/translate.lua
+++ b/translate-widget/translate.lua
@@ -12,6 +12,7 @@ local https = require("ssl.https")
local json = require("json")
local naughty = require("naughty")
local wibox = require("wibox")
+local gears = require("gears")
local API_KEY = '<your api key>'
local BASE_URL = 'https://translate.yandex.net/api/v1.5/tr.json/translate'
@@ -41,11 +42,17 @@ end
local w = wibox {
width = 300,
+ border_width = 1,
+ border_color = '#66ccff',
ontop = true,
screen = mouse.screen,
expand = true,
bg = '#1e252c',
- max_widget_size = 500
+ max_widget_size = 500,
+ shape = function(cr, width, height)
+ gears.shape.rounded_rect(cr, width, height, 3)
+ end
+
}
w:setup {
@@ -140,6 +147,11 @@ local input_widget = wibox {
bg = '#1e252c',
max_widget_size = 500,
border_width = 1;
+ border_width = 1,
+ border_color = '#66ccff',
+ shape = function(cr, width, height)
+ gears.shape.rounded_rect(cr, width, height, 3)
+ end
}
local prompt = awful.widget.prompt()