summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bitbucket-widget/bitbucket.lua2
-rw-r--r--experiments/volume/utils.lua1
-rw-r--r--experiments/volume/volume.lua45
-rw-r--r--experiments/volume/widgets/arc-widget.lua (renamed from experiments/volume/arc-widget.lua)6
-rw-r--r--experiments/volume/widgets/icon-and-text-widget.lua (renamed from experiments/volume/icon-and-text-widget.lua)27
-rw-r--r--experiments/volume/widgets/icon-widget.lua43
-rw-r--r--fs-widget/fs-widget.lua9
-rw-r--r--github-activity-widget/github-activity-widget.lua9
-rw-r--r--github-activity-widget/icons/alert-circle.svg1
-rw-r--r--github-activity-widget/icons/comment.svg1
-rw-r--r--github-activity-widget/icons/fork.svg1
-rw-r--r--github-activity-widget/icons/git-branch.svg1
-rw-r--r--github-activity-widget/icons/git-pull-request.svg1
-rw-r--r--github-activity-widget/icons/issue.svg1
-rw-r--r--github-activity-widget/icons/message-square.svg1
-rw-r--r--github-activity-widget/icons/pr.svg1
-rw-r--r--github-activity-widget/icons/star.svg2
-rw-r--r--github-contributions-widget/README.md37
-rw-r--r--github-contributions-widget/github-contributions-widget.lua36
-rw-r--r--github-contributions-widget/screenshots/Thomashighbaugh.pngbin0 -> 384 bytes
-rw-r--r--github-contributions-widget/screenshots/classic.pngbin0 -> 494 bytes
-rw-r--r--github-contributions-widget/screenshots/dracula.pngbin0 -> 497 bytes
-rw-r--r--github-contributions-widget/screenshots/leftpad.pngbin0 -> 409 bytes
-rw-r--r--github-contributions-widget/screenshots/pink.pngbin0 -> 409 bytes
-rw-r--r--github-contributions-widget/screenshots/screenshot.jpg (renamed from github-contributions-widget/screenshot.jpg)bin14613 -> 14613 bytes
-rw-r--r--github-contributions-widget/screenshots/screenshot1.jpg (renamed from github-contributions-widget/screenshot1.jpg)bin10879 -> 10879 bytes
-rw-r--r--github-contributions-widget/screenshots/screenshot2.jpg (renamed from github-contributions-widget/screenshot2.jpg)bin6164 -> 6164 bytes
-rw-r--r--github-contributions-widget/screenshots/standard.pngbin0 -> 408 bytes
-rw-r--r--github-contributions-widget/screenshots/teal.pngbin0 -> 409 bytes
-rw-r--r--github-contributions-widget/themes.lua46
-rw-r--r--gitlab-widget/gitlab.lua55
-rw-r--r--logout-widget/README.md2
-rw-r--r--logout-widget/logout.lua2
-rw-r--r--run-shell-3/run-shell.lua4
-rw-r--r--spotify-widget/README.md2
-rw-r--r--spotify-widget/spotify.lua32
-rw-r--r--translate-widget/gnome-translate.svg12
-rw-r--r--translate-widget/translate.lua174
-rw-r--r--weather-widget/weather.lua1
39 files changed, 395 insertions, 160 deletions
diff --git a/bitbucket-widget/bitbucket.lua b/bitbucket-widget/bitbucket.lua
index dc7a34d..8d47f2f 100644
--- a/bitbucket-widget/bitbucket.lua
+++ b/bitbucket-widget/bitbucket.lua
@@ -238,7 +238,7 @@ local function worker(args)
{
{
{
- image = number_of_approves > 0 and WIDGET_DIR .. '/check.svg' or '',
+ image = WIDGET_DIR .. '/check.svg',
resize = false,
widget = wibox.widget.imagebox
},
diff --git a/experiments/volume/utils.lua b/experiments/volume/utils.lua
index 02742ec..dcaeb84 100644
--- a/experiments/volume/utils.lua
+++ b/experiments/volume/utils.lua
@@ -99,7 +99,6 @@ function utils.extract_sinks_and_sources(pacmd_output)
ports[key] = t[2]
end
end
- print(json.encode(sources))
return sinks, sources
end
diff --git a/experiments/volume/volume.lua b/experiments/volume/volume.lua
index ae7605e..9110a45 100644
--- a/experiments/volume/volume.lua
+++ b/experiments/volume/volume.lua
@@ -14,8 +14,6 @@ local gears = require("gears")
local beautiful = require("beautiful")
local watch = require("awful.widget.watch")
local utils = require("awesome-wm-widgets.experiments.volume.utils")
-local arc_widget = require("awesome-wm-widgets.experiments.volume.arc-widget")
-local icon_and_text_widget = require("awesome-wm-widgets.experiments.volume.icon-and-text-widget")
local LIST_DEVICES_CMD = [[sh -c "pacmd list-sinks; pacmd list-sources"]]
@@ -25,6 +23,12 @@ local DEC_VOLUME_CMD = 'amixer -q -D pulse sset Master 5%-'
local TOG_VOLUME_CMD = 'amixer -q -D pulse sset Master toggle'
+local widget_types = {
+ icon_and_text = require("awesome-wm-widgets.experiments.volume.widgets.icon-and-text-widget"),
+ icon = require("awesome-wm-widgets.experiments.volume.widgets.icon-widget"),
+ arc = require("awesome-wm-widgets.experiments.volume.widgets.arc-widget")
+}
+
local volume_widget = wibox.widget{}
local rows = { layout = wibox.layout.fixed.vertical }
@@ -43,7 +47,7 @@ local popup = awful.popup{
local function build_main_line(device)
if device.active_port ~= nil and device.ports[device.active_port] ~= nil then
- return device.properties.device_description .. ' - ' .. device.ports[device.active_port]
+ return device.properties.device_description .. ' ยท ' .. device.ports[device.active_port]
else
return device.properties.device_description
end
@@ -90,13 +94,35 @@ local function build_rows(devices, on_checkbox_click, device_type)
spacing = 8,
layout = wibox.layout.align.horizontal
},
- margins = 8,
+ margins = 4,
layout = wibox.container.margin
},
bg = beautiful.bg_normal,
widget = wibox.container.background
}
+ row:connect_signal("mouse::enter", function(c) c:set_bg(beautiful.bg_focus) end)
+ row:connect_signal("mouse::leave", function(c) c:set_bg(beautiful.bg_normal) end)
+
+ local old_cursor, old_wibox
+ row:connect_signal("mouse::enter", function(c)
+ local wb = mouse.current_wibox
+ old_cursor, old_wibox = wb.cursor, wb
+ wb.cursor = "hand1"
+ end)
+ row:connect_signal("mouse::leave", function(c)
+ if old_wibox then
+ old_wibox.cursor = old_cursor
+ old_wibox = nil
+ end
+ end)
+
+ row:connect_signal("button::press", function(c)
+ spawn.easy_async(string.format([[sh -c 'pacmd set-default-%s "%s"']], device_type, device.name), function()
+ on_checkbox_click()
+ end)
+ end)
+
table.insert(device_rows, row)
end
@@ -134,8 +160,15 @@ end
local function worker(args)
- volume_widget = arc_widget.get_widget()
- -- volume_widget = icon_and_text_widget.get_widget()
+ local args = args or {}
+
+ local widget_type = args.widget_type
+
+ if widget_types[widget_type] == nil then
+ volume_widget = widget_types['icon_and_text'].get_widget()
+ else
+ volume_widget = widget_types[widget_type].get_widget()
+ end
volume_widget:buttons(
awful.util.table.join(
diff --git a/experiments/volume/arc-widget.lua b/experiments/volume/widgets/arc-widget.lua
index fb56518..d7a3b1f 100644
--- a/experiments/volume/arc-widget.lua
+++ b/experiments/volume/widgets/arc-widget.lua
@@ -1,6 +1,8 @@
local wibox = require("wibox")
local beautiful = require('beautiful')
+local ICON_DIR = os.getenv("HOME") .. '/.config/awesome/awesome-wm-widgets/experiments/volume/icons/'
+
local widget = {}
function widget.get_widget()
@@ -8,7 +10,7 @@ function widget.get_widget()
return wibox.widget {
{
id = "icon",
- image = '/usr/share/icons/Arc/status/symbolic/audio-volume-muted-symbolic.svg',
+ image = ICON_DIR .. 'audio-volume-high-symbolic.svg',
resize = true,
widget = wibox.widget.imagebox,
},
@@ -28,7 +30,7 @@ function widget.get_widget()
end,
unmute = function(self)
self.colors = {beautiful.fg_color}
- end
+ end
}
end
diff --git a/experiments/volume/icon-and-text-widget.lua b/experiments/volume/widgets/icon-and-text-widget.lua
index 929d32d..5517f11 100644
--- a/experiments/volume/icon-and-text-widget.lua
+++ b/experiments/volume/widgets/icon-and-text-widget.lua
@@ -10,7 +10,6 @@ function widget.get_widget()
{
{
id = "icon",
- image = '/usr/share/icons/Arc/status/symbolic/audio-volume-muted-symbolic.svg',
resize = false,
widget = wibox.widget.imagebox,
},
@@ -22,21 +21,31 @@ function widget.get_widget()
widget = wibox.widget.textbox
},
layout = wibox.layout.fixed.horizontal,
+ is_muted = true,
set_volume_level = function(self, new_value)
self:get_children_by_id('txt')[1]:set_text(new_value)
- local new_value_num = tonumber(new_value)
local volume_icon_name = ''
- if (new_value_num >= 0 and new_value_num < 33) then
- volume_icon_name="audio-volume-low-symbolic"
- elseif (new_value_num < 66) then
- volume_icon_name="audio-volume-medium-symbolic"
+ if self.is_muted then
+ volume_icon_name = 'audio-volume-muted-symbolic.svg'
else
- volume_icon_name="audio-volume-high-symbolic"
+ local new_value_num = tonumber(new_value)
+ if (new_value_num >= 0 and new_value_num < 33) then
+ volume_icon_name="audio-volume-low-symbolic"
+ elseif (new_value_num < 66) then
+ volume_icon_name="audio-volume-medium-symbolic"
+ else
+ volume_icon_name="audio-volume-high-symbolic"
+ end
end
self:get_children_by_id('icon')[1]:set_image(WIDGET_DIR .. volume_icon_name .. '.svg')
end,
- mute = function(self) self:get_children_by_id('icon')[1]:set_image(WIDGET_DIR .. 'audio-volume-muted-symbolic.svg') end,
- unmute = function() end,
+ mute = function(self)
+ self.is_muted = true
+ self:get_children_by_id('icon')[1]:set_image(WIDGET_DIR .. 'audio-volume-muted-symbolic.svg')
+ end,
+ unmute = function(self)
+ self.is_muted = false
+ end,
}
diff --git a/experiments/volume/widgets/icon-widget.lua b/experiments/volume/widgets/icon-widget.lua
new file mode 100644
index 0000000..2a20dde
--- /dev/null
+++ b/experiments/volume/widgets/icon-widget.lua
@@ -0,0 +1,43 @@
+local wibox = require("wibox")
+
+local widget = {}
+
+local WIDGET_DIR = os.getenv("HOME") .. '/.config/awesome/awesome-wm-widgets/experiments/volume/icons/'
+
+function widget.get_widget()
+
+ return wibox.widget {
+ {
+ id = "icon",
+ resize = false,
+ widget = wibox.widget.imagebox,
+ },
+ valign = 'center',
+ layout = wibox.container.place,
+ set_volume_level = function(self, new_value)
+ local volume_icon_name = ''
+ if self.is_muted then
+ volume_icon_name = 'audio-volume-muted-symbolic.svg'
+ else
+ local new_value_num = tonumber(new_value)
+ if (new_value_num >= 0 and new_value_num < 33) then
+ volume_icon_name="audio-volume-low-symbolic"
+ elseif (new_value_num < 66) then
+ volume_icon_name="audio-volume-medium-symbolic"
+ else
+ volume_icon_name="audio-volume-high-symbolic"
+ end
+ end
+ self:get_children_by_id('icon')[1]:set_image(WIDGET_DIR .. volume_icon_name .. '.svg')
+ end,
+ mute = function(self)
+ self.is_muted = true
+ self:get_children_by_id('icon')[1]:set_image(WIDGET_DIR .. 'audio-volume-muted-symbolic.svg')
+ end,
+ unmute = function(self)
+ self.is_muted = false
+ end
+ }
+end
+
+return widget \ No newline at end of file
diff --git a/fs-widget/fs-widget.lua b/fs-widget/fs-widget.lua
index 343c9f3..613c472 100644
--- a/fs-widget/fs-widget.lua
+++ b/fs-widget/fs-widget.lua
@@ -35,7 +35,7 @@ local function worker(args)
layout = wibox.layout.fixed.vertical,
}
- local disk_header = {
+ local disk_header = wibox.widget{
{
markup = '<b>Mount</b>',
forced_width = 150,
@@ -47,8 +47,9 @@ local function worker(args)
align = 'left',
widget = wibox.widget.textbox,
},
- layout = wibox.layout.align.horizontal
+ layout = wibox.layout.ratio.horizontal
}
+ disk_header:ajust_ratio(1, 0, 0.3, 0.7)
local popup = awful.popup{
ontop = true,
@@ -56,7 +57,6 @@ local function worker(args)
shape = gears.shape.rounded_rect,
border_width = 1,
border_color = beautiful.bg_normal,
- bg = beautiful.bg_focus,
maximum_width = 400,
offset = { y = 5 },
widget = {}
@@ -131,8 +131,9 @@ local function worker(args)
.. math.floor(disks[v].perc) .. '%)',
widget = wibox.widget.textbox
},
- layout = wibox.layout.align.horizontal
+ layout = wibox.layout.ratio.horizontal
}
+ row:ajust_ratio(2, 0.3, 0.3, 0.4)
disk_rows[k] = row
end
diff --git a/github-activity-widget/github-activity-widget.lua b/github-activity-widget/github-activity-widget.lua
index 4af0c13..84b5320 100644
--- a/github-activity-widget/github-activity-widget.lua
+++ b/github-activity-widget/github-activity-widget.lua
@@ -83,21 +83,21 @@ local function generate_action_string(event)
if (event.type == "PullRequestEvent") then
action_string = event.action .. ' a pull request in'
link = event.pr_url
- icon = 'pr.svg'
+ icon = 'git-pull-request.svg'
elseif (event.type == "IssuesEvent") then
action_string = event.action .. ' an issue in'
link = event.issue_url
- icon = 'issue.svg'
+ icon = 'alert-circle.svg'
elseif (event.type == "IssueCommentEvent") then
action_string = event.action == 'created' and 'commented in issue' or event.action .. ' a comment in'
link = event.issue_url
- icon = 'comment.svg'
+ icon = 'message-square.svg'
elseif (event.type == "WatchEvent") then
action_string = 'starred'
icon = 'star.svg'
elseif (event.type == "ForkEvent") then
action_string = 'forked'
- icon = 'fork.svg'
+ icon = 'git-branch.svg'
elseif (event.type == "CreateEvent") then
action_string = 'created'
end
@@ -144,7 +144,6 @@ local function worker(args)
github_widget:set_icon(icon)
local rows = {
- { widget = wibox.widget.textbox },
layout = wibox.layout.fixed.vertical,
}
diff --git a/github-activity-widget/icons/alert-circle.svg b/github-activity-widget/icons/alert-circle.svg
new file mode 100644
index 0000000..1c42eaf
--- /dev/null
+++ b/github-activity-widget/icons/alert-circle.svg
@@ -0,0 +1 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="#ECEFF4" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-alert-circle"><circle cx="12" cy="12" r="10"></circle><line x1="12" y1="8" x2="12" y2="12"></line><line x1="12" y1="16" x2="12.01" y2="16"></line></svg> \ No newline at end of file
diff --git a/github-activity-widget/icons/comment.svg b/github-activity-widget/icons/comment.svg
deleted file mode 100644
index 5cb54bf..0000000
--- a/github-activity-widget/icons/comment.svg
+++ /dev/null
@@ -1 +0,0 @@
-<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16"><style type="text/css"><![CDATA[.white{fill: #ffffff;}]]></style><path class="white" fill-rule="evenodd" d="M14 1H2c-.55 0-1 .45-1 1v8c0 .55.45 1 1 1h2v3.5L7.5 11H14c.55 0 1-.45 1-1V2c0-.55-.45-1-1-1zm0 9H7l-2 2v-2H2V2h12v8z"></path></svg> \ No newline at end of file
diff --git a/github-activity-widget/icons/fork.svg b/github-activity-widget/icons/fork.svg
deleted file mode 100644
index 4c722dc..0000000
--- a/github-activity-widget/icons/fork.svg
+++ /dev/null
@@ -1 +0,0 @@
-<?xml version="1.0" ?><svg height="1024" width="640" xmlns="http://www.w3.org/2000/svg"><style type="text/css"><![CDATA[.white{fill: #ffffff;}]]></style><path class="white" d="M512 192c-70.625 0-128 57.344-128 128 0 47.219 25.875 88.062 64 110.281V448c0 0 0 128-128 128-53.062 0-94.656 11.375-128 28.812V302.28099999999995c38.156-22.219 64-63.062 64-110.281 0-70.656-57.344-128-128-128S0 121.34400000000005 0 192c0 47.219 25.844 88.062 64 110.281V721.75C25.844 743.938 0 784.75 0 832c0 70.625 57.344 128 128 128s128-57.375 128-128c0-33.5-13.188-63.75-34.25-86.625C240.375 722.5 270.656 704 320 704c254 0 256-256 256-256v-17.719c38.125-22.219 64-63.062 64-110.281C640 249.34400000000005 582.625 192 512 192zM128 128c35.406 0 64 28.594 64 64s-28.594 64-64 64-64-28.594-64-64S92.594 128 128 128zM128 896c-35.406 0-64-28.625-64-64 0-35.312 28.594-64 64-64s64 28.688 64 64C192 867.375 163.406 896 128 896zM512 384c-35.375 0-64-28.594-64-64s28.625-64 64-64 64 28.594 64 64S547.375 384 512 384z"/></svg> \ No newline at end of file
diff --git a/github-activity-widget/icons/git-branch.svg b/github-activity-widget/icons/git-branch.svg
new file mode 100644
index 0000000..3f06c34
--- /dev/null
+++ b/github-activity-widget/icons/git-branch.svg
@@ -0,0 +1 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="#ECEFF4" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-git-branch"><line x1="6" y1="3" x2="6" y2="15"></line><circle cx="18" cy="6" r="3"></circle><circle cx="6" cy="18" r="3"></circle><path d="M18 9a9 9 0 0 1-9 9"></path></svg> \ No newline at end of file
diff --git a/github-activity-widget/icons/git-pull-request.svg b/github-activity-widget/icons/git-pull-request.svg
new file mode 100644
index 0000000..c2e2867
--- /dev/null
+++ b/github-activity-widget/icons/git-pull-request.svg
@@ -0,0 +1 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="#ECEFF4" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-git-pull-request"><circle cx="18" cy="18" r="3"></circle><circle cx="6" cy="6" r="3"></circle><path d="M13 6h3a2 2 0 0 1 2 2v7"></path><line x1="6" y1="9" x2="6" y2="21"></line></svg> \ No newline at end of file
diff --git a/github-activity-widget/icons/issue.svg b/github-activity-widget/icons/issue.svg
deleted file mode 100644
index b47543a..0000000
--- a/github-activity-widget/icons/issue.svg
+++ /dev/null
@@ -1 +0,0 @@
-<?xml version="1.0" ?><svg height="1024" width="896" xmlns="http://www.w3.org/2000/svg"><style type="text/css"><![CDATA[.white{fill: #ffffff;}]]></style><path class="white" d="M448 64C200.562 64 0 264.562 0 512c0 247.438 200.562 448 448 448 247.438 0 448-200.562 448-448C896 264.562 695.438 64 448 64zM448 832c-176.781 0-320-143.25-320-320 0-176.781 143.219-320 320-320 176.75 0 320 143.219 320 320C768 688.75 624.75 832 448 832zM384 768h128V640H384V768zM384 576h128V256H384V576z"/></svg> \ No newline at end of file
diff --git a/github-activity-widget/icons/message-square.svg b/github-activity-widget/icons/message-square.svg
new file mode 100644
index 0000000..758ba42
--- /dev/null
+++ b/github-activity-widget/icons/message-square.svg
@@ -0,0 +1 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="#ECEFF4" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-message-square"><path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"></path></svg> \ No newline at end of file
diff --git a/github-activity-widget/icons/pr.svg b/github-activity-widget/icons/pr.svg
deleted file mode 100644
index 412be1a..0000000
--- a/github-activity-widget/icons/pr.svg
+++ /dev/null
@@ -1 +0,0 @@
-<?xml version="1.0" ?><svg height="1024" width="768" xmlns="http://www.w3.org/2000/svg"><style type="text/css"><![CDATA[.white{fill: #ffffff;}]]></style><path class="white" d="M128 64C57.344 64 0 121.34400000000005 0 192c0 47.219 25.906 88.062 64 110.281V721.75C25.906 743.938 0 784.75 0 832c0 70.625 57.344 128 128 128s128-57.375 128-128c0-47.25-25.844-88.062-64-110.25V302.28099999999995c38.156-22.219 64-63.062 64-110.281C256 121.34400000000005 198.656 64 128 64zM128 896c-35.312 0-64-28.625-64-64 0-35.312 28.688-64 64-64 35.406 0 64 28.688 64 64C192 867.375 163.406 896 128 896zM128 256c-35.312 0-64-28.594-64-64s28.688-64 64-64c35.406 0 64 28.594 64 64S163.406 256 128 256zM704 721.75V320c0-192.5-192-192-192-192h-64V0L256 192l192 192V256c0 0 26.688 0 64 0 56.438 0 64 64 64 64v401.75c-38.125 22.188-64 62.938-64 110.25 0 70.625 57.375 128 128 128s128-57.375 128-128C768 784.75 742.125 743.938 704 721.75zM640 896c-35.312 0-64-28.625-64-64 0-35.312 28.688-64 64-64 35.375 0 64 28.688 64 64C704 867.375 675.375 896 640 896z"/></svg> \ No newline at end of file
diff --git a/github-activity-widget/icons/star.svg b/github-activity-widget/icons/star.svg
index 7ac51ac..0a3d39e 100644
--- a/github-activity-widget/icons/star.svg
+++ b/github-activity-widget/icons/star.svg
@@ -1 +1 @@
-<?xml version="1.0" ?><svg height="1024" width="896" xmlns="http://www.w3.org/2000/svg"><style type="text/css"><![CDATA[.white{fill: #ffffff;}]]></style><path class="white" d="M896 384l-313.5-40.781L448 64 313.469 343.219 0 384l230.469 208.875L171 895.938l277-148.812 277.062 148.812L665.5 592.875 896 384z"/></svg> \ No newline at end of file
+<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="#ECEFF4" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-star"><polygon points="12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"></polygon></svg> \ No newline at end of file
diff --git a/github-contributions-widget/README.md b/github-contributions-widget/README.md
index b7f6b93..7d02008 100644
--- a/github-contributions-widget/README.md
+++ b/github-contributions-widget/README.md
@@ -1,8 +1,12 @@
# Github Contributions Widget
-Shows the contribution graph, similar to the one on the github profile page:
+The widget is inspired by the https://github-contributions.now.sh/ and relies on it's API.
-![screenshot](./screenshot.jpg)
+It shows the contribution graph, similar to the one on the github profile page: ![screenshot](./screenshots/screenshot.jpg)
+
+You might wonder what could be the reason to have your github's contributions in front of you all day long? The more you contribute, the nicer widget looks! Check out [Thomashighbaugh](https://github.com/Thomashighbaugh)'s graph:
+
+![](./screenshots/Thomashighbaugh.png)
## Customization
@@ -10,20 +14,37 @@ It is possible to customize the widget by providing a table with all or some of
| Name | Default | Description |
|---|---|---|
-| `username` | 'streetturtle' | Username |
+| `username` | `streetturtle` | GitHub username |
| `days` | `365` | Number of days in the past, more days - wider the widget |
-| `empty_color` | `beautiful.bg_normal` | Color of the days with no contributions |
+| `color_of_empty_cells` | Theme's default | Color of the days with no contributions |
| `with_border` | `true` | Should the graph contains border or not |
| `margin_top` | `1` | Top margin |
+| `theme` | `standard` | Color theme of the graph, see below |
+
+_Note:_ widget height is 21px (7 rows of 3x3 cells). So it would look nice on the wibar of 22-24px height.
+
+### Themes
-Few more screenshots:
+Following themes are available:
+
+| Theme name | Preview |
+|---|---|
+| standard | ![standard](./screenshots/standard.png) |
+| classic | ![classic](./screenshots/classic.png) |
+| teal | ![teal](./screenshots/teal.png) |
+| leftpad | ![leftpad](./screenshots/leftpad.png) |
+| dracula | ![dracula](./screenshots/dracula.png) |
+| pink | ![pink](./screenshots/pink.png) |
+
+To add a new theme, simply add a new entry in `themes` table (themes.lua) with the colors of your theme.
+
+### Screenshots
1000 days, with border:
-![screenshot1](./screenshot1.jpg)
+![screenshot1](./screenshots/screenshot1.jpg)
365 days, no border:
-![screenshot2](./screenshot2.jpg)
-
+![screenshot2](./screenshots/screenshot2.jpg)
## Installation
diff --git a/github-contributions-widget/github-contributions-widget.lua b/github-contributions-widget/github-contributions-widget.lua
index 3025d17..b462299 100644
--- a/github-contributions-widget/github-contributions-widget.lua
+++ b/github-contributions-widget/github-contributions-widget.lua
@@ -9,12 +9,11 @@
-------------------------------------------------
local awful = require("awful")
+local naughty = require("naughty")
local wibox = require("wibox")
-local beautiful = require("beautiful")
+local widget_themes = require("awesome-wm-widgets.github-contributions-widget.themes")
local GET_CONTRIBUTIONS_CMD = [[bash -c "curl -s https://github-contributions.now.sh/api/v1/%s | jq -r '[.contributions[] | select ( .date | strptime(\"%%Y-%%m-%%d\") | mktime < now)][:%s]| .[].color'"]]
--- in case github-contributions.now.sh stops working contributions can be scrapped from the github.com with the command below. Note that the order is reversed.
-local GET_CONTRIBUTIONS_CMD_FALLBACK = [[bash -c "curl -s https://github.com/users/%s/contributions | grep -o '\" fill=\"\#[0-9a-fA-F]\{6\}\" da' | grep -o '\#[0-9a-fA-F]\{6\}'"]]
local github_contributions_widget = wibox.widget{
reflection = {
@@ -24,24 +23,39 @@ local github_contributions_widget = wibox.widget{
widget = wibox.container.mirror
}
+local function show_warning(message)
+ naughty.notify{
+ preset = naughty.config.presets.critical,
+ title = 'Github Contributions Widget',
+ text = message}
+end
+
local function worker(args)
local args = args or {}
local username = args.username or 'streetturtle'
local days = args.days or 365
- local empty_color = args.empty_color or beautiful.bg_normal
+ local color_of_empty_cells = args.color_of_empty_cells
local with_border = args.with_border
local margin_top = args.margin_top or 1
+ local theme = args.theme or 'standard'
+
+ if widget_themes[theme] == nil then
+ show_warning('Theme ' .. theme .. ' does not exist')
+ theme = 'standard'
+ end
if with_border == nil then with_border = true end
local function hex2rgb(hex)
- if hex == '#ebedf0' then hex = empty_color end
- hex = tostring(hex):gsub("#","")
- return tonumber("0x" .. hex:sub(1, 2)),
- tonumber("0x" .. hex:sub(3, 4)),
- tonumber("0x" .. hex:sub(5, 6))
+ if color_of_empty_cells ~= nil and hex == widget_themes[theme]['color_calendar_graph_day_bg'] then
+ hex = color_of_empty_cells
+ end
+ hex = tostring(hex):gsub('#','')
+ return tonumber('0x' .. hex:sub(1, 2)),
+ tonumber('0x' .. hex:sub(3, 4)),
+ tonumber('0x' .. hex:sub(5, 6))
end
local function get_square(color)
@@ -64,7 +78,7 @@ local function worker(args)
local row = {layout = wibox.layout.fixed.horizontal}
local a = 5 - os.date('%w')
for i = 0, a do
- table.insert(col, get_square('#ebedf0'))
+ table.insert(col, get_square(color_of_empty_cells))
end
local update_widget = function(widget, stdout, _, _, _)
@@ -73,7 +87,7 @@ local function worker(args)
table.insert(row, col)
col = {layout = wibox.layout.fixed.vertical}
end
- table.insert(col, get_square(colors))
+ table.insert(col, get_square(widget_themes[theme][colors:match('var%(%-%-(.*)%)'):gsub('-', '_')]))
a = a + 1
end
github_contributions_widget:setup(
diff --git a/github-contributions-widget/screenshots/Thomashighbaugh.png b/github-contributions-widget/screenshots/Thomashighbaugh.png
new file mode 100644
index 0000000..b31245b
--- /dev/null
+++ b/github-contributions-widget/screenshots/Thomashighbaugh.png
Binary files differ
diff --git a/github-contributions-widget/screenshots/classic.png b/github-contributions-widget/screenshots/classic.png
new file mode 100644
index 0000000..4652140
--- /dev/null
+++ b/github-contributions-widget/screenshots/classic.png
Binary files differ
diff --git a/github-contributions-widget/screenshots/dracula.png b/github-contributions-widget/screenshots/dracula.png
new file mode 100644
index 0000000..65fb769
--- /dev/null
+++ b/github-contributions-widget/screenshots/dracula.png
Binary files differ
diff --git a/github-contributions-widget/screenshots/leftpad.png b/github-contributions-widget/screenshots/leftpad.png
new file mode 100644
index 0000000..19e4f64
--- /dev/null
+++ b/github-contributions-widget/screenshots/leftpad.png
Binary files differ
diff --git a/github-contributions-widget/screenshots/pink.png b/github-contributions-widget/screenshots/pink.png
new file mode 100644
index 0000000..2fb7bc6
--- /dev/null
+++ b/github-contributions-widget/screenshots/pink.png
Binary files differ
diff --git a/github-contributions-widget/screenshot.jpg b/github-contributions-widget/screenshots/screenshot.jpg
index 15ad456..15ad456 100644
--- a/github-contributions-widget/screenshot.jpg
+++ b/github-contributions-widget/screenshots/screenshot.jpg
Binary files differ
diff --git a/github-contributions-widget/screenshot1.jpg b/github-contributions-widget/screenshots/screenshot1.jpg
index d1eeb44..d1eeb44 100644
--- a/github-contributions-widget/screenshot1.jpg
+++ b/github-contributions-widget/screenshots/screenshot1.jpg
Binary files differ
diff --git a/github-contributions-widget/screenshot2.jpg b/github-contributions-widget/screenshots/screenshot2.jpg
index 5ce47f2..5ce47f2 100644
--- a/github-contributions-widget/screenshot2.jpg
+++ b/github-contributions-widget/screenshots/screenshot2.jpg
Binary files differ
diff --git a/github-contributions-widget/screenshots/standard.png b/github-contributions-widget/screenshots/standard.png
new file mode 100644
index 0000000..e10479a
--- /dev/null
+++ b/github-contributions-widget/screenshots/standard.png
Binary files differ
diff --git a/github-contributions-widget/screenshots/teal.png b/github-contributions-widget/screenshots/teal.png
new file mode 100644
index 0000000..f10de7a
--- /dev/null
+++ b/github-contributions-widget/screenshots/teal.png
Binary files differ
diff --git a/github-contributions-widget/themes.lua b/github-contributions-widget/themes.lua
new file mode 100644
index 0000000..a263d1c
--- /dev/null
+++ b/github-contributions-widget/themes.lua
@@ -0,0 +1,46 @@
+local themes = {
+ standard = {
+ color_calendar_graph_day_L4_bg = '#216e39',
+ color_calendar_graph_day_L3_bg = '#30a14e',
+ color_calendar_graph_day_L2_bg = '#40c463',
+ color_calendar_graph_day_L1_bg = '#9be9a8',
+ color_calendar_graph_day_bg = '#ebedf0'
+ },
+ classic = {
+ color_calendar_graph_day_L4_bg = '#196127',
+ color_calendar_graph_day_L3_bg = '#239a3b',
+ color_calendar_graph_day_L2_bg = '#7bc96f',
+ color_calendar_graph_day_L1_bg = '#c6e48b',
+ color_calendar_graph_day_bg = '#ebedf0',
+ },
+ teal = {
+ color_calendar_graph_day_L4_bg = '#458B74',
+ color_calendar_graph_day_L3_bg = '#66CDAA',
+ color_calendar_graph_day_L2_bg = '#76EEC6',
+ color_calendar_graph_day_L1_bg = '#7FFFD4',
+ color_calendar_graph_day_bg = '#ebedf0',
+ },
+ leftpad = {
+ color_calendar_graph_day_L4_bg = '#F6F6F6',
+ color_calendar_graph_day_L3_bg = '#DDDDDD',
+ color_calendar_graph_day_L2_bg = '#A5A5A5',
+ color_calendar_graph_day_L1_bg = '#646464',
+ color_calendar_graph_day_bg = '#2F2F2F',
+ },
+ dracula = {
+ color_calendar_graph_day_L4_bg = '#ff79c6',
+ color_calendar_graph_day_L3_bg = '#bd93f9',
+ color_calendar_graph_day_L2_bg = '#6272a4',
+ color_calendar_graph_day_L1_bg = '#44475a',
+ color_calendar_graph_day_bg = '#282a36'
+ },
+ pink = {
+ color_calendar_graph_day_L4_bg = '#61185f',
+ color_calendar_graph_day_L3_bg = '#a74aa8',
+ color_calendar_graph_day_L2_bg = '#ca5bcc',
+ color_calendar_graph_day_L1_bg = '#e48bdc',
+ color_calendar_graph_day_bg = '#ebedf0',
+ }
+}
+
+return themes \ No newline at end of file
diff --git a/gitlab-widget/gitlab.lua b/gitlab-widget/gitlab.lua
index 7a70113..3482347 100644
--- a/gitlab-widget/gitlab.lua
+++ b/gitlab-widget/gitlab.lua
@@ -17,17 +17,31 @@ local naughty = require("naughty")
local gears = require("gears")
local beautiful = require("beautiful")
local gfs = require("gears.filesystem")
+local color = require("gears.color")
local HOME_DIR = os.getenv("HOME")
local WIDGET_DIR = HOME_DIR .. '/.config/awesome/awesome-wm-widgets/gitlab-widget/'
-local GET_PRS_CMD= [[bash -c "curl -s --show-error --header 'PRIVATE-TOKEN: %s' '%s/api/v4/merge_requests?state=opened'"]]
-local DOWNLOAD_AVATAR_CMD = [[bash -c "curl -L -n --create-dirs -o %s/.cache/awmw/gitlab-widget/avatars/%s %s"]]
+local GET_PRS_CMD= [[bash -c "curl -s --connect-timeout 5 --show-error --header 'PRIVATE-TOKEN: %s' '%s/api/v4/merge_requests?state=opened'"]]
+local DOWNLOAD_AVATAR_CMD = [[bash -c "curl -L --create-dirs -o %s/.cache/awmw/gitlab-widget/avatars/%s %s"]]
local gitlab_widget = wibox.widget {
{
{
- id = 'icon',
- widget = wibox.widget.imagebox
+ {
+ id = 'icon',
+ widget = wibox.widget.imagebox
+ },
+ {
+ id = 'error_marker',
+ draw = function(self, context, cr, width, height)
+ cr:set_source(color(beautiful.fg_urgent))
+ cr:arc(height/4, height/4, height/4, 0, math.pi*2)
+ cr:fill()
+ end,
+ visible = false,
+ layout = wibox.widget.base.make_widget,
+ },
+ layout = wibox.layout.stack
},
margins = 4,
layout = wibox.container.margin
@@ -46,6 +60,18 @@ local gitlab_widget = wibox.widget {
end,
set_icon = function(self, new_value)
self:get_children_by_id('icon')[1]:set_image(new_value)
+ end,
+ is_everything_ok = function(self, is_ok)
+ if is_ok then
+ self:get_children_by_id('error_marker')[1]:set_visible(false)
+ self:get_children_by_id('icon')[1]:set_opacity(1)
+ self:get_children_by_id('icon')[1]:emit_signal('widget:redraw_needed')
+ else
+ self.txt:set_text('')
+ self:get_children_by_id('error_marker')[1]:set_visible(true)
+ self:get_children_by_id('icon')[1]:set_opacity(0.2)
+ self:get_children_by_id('icon')[1]:emit_signal('widget:redraw_needed')
+ end
end
}
@@ -102,6 +128,12 @@ local function ellipsize(text, length)
or text
end
+local warning_shown = false
+local tooltip = awful.tooltip {
+ mode = 'outside',
+ preferred_positions = {'bottom'},
+ }
+
local function worker(args)
local args = args or {}
@@ -122,10 +154,23 @@ local function worker(args)
local update_widget = function(widget, stdout, stderr, _, _)
if stderr ~= '' then
- show_warning(stderr)
+ if not warning_shown then
+ show_warning(stderr)
+ warning_shown = true
+ widget:is_everything_ok(false)
+ tooltip:add_to_object(widget)
+
+ widget:connect_signal('mouse::enter', function()
+ tooltip.text = stderr
+ end)
+ end
return
end
+ warning_shown = false
+ tooltip:remove_from_object(widget)
+ widget:is_everything_ok(true)
+
local result = json.decode(stdout)
current_number_of_prs = rawlen(result)
diff --git a/logout-widget/README.md b/logout-widget/README.md
index 7d1673d..e4d095d 100644
--- a/logout-widget/README.md
+++ b/logout-widget/README.md
@@ -38,7 +38,7 @@ Then
- to show by clicking on a widget in wibar - add widget to the wibar:
```lua
- local logout = require("awesome-wm-widgets.experiments.logout-widget.logout")
+ local logout = require("awesome-wm-widgets.logout-widget.logout")
s.mytasklist, -- Middle widget
{ -- Right widgets
diff --git a/logout-widget/logout.lua b/logout-widget/logout.lua
index b8835a6..9fcc9fe 100644
--- a/logout-widget/logout.lua
+++ b/logout-widget/logout.lua
@@ -51,6 +51,7 @@ local function create_button(icon_name, action_name, color, onclick, icon_size,
onclick = function()
onclick()
w.visible = false
+ capi.keygrabber.stop()
end
}
button:connect_signal("mouse::enter", function(c) action:set_text(action_name) end)
@@ -109,6 +110,7 @@ local function launch(args)
layout = wibox.container.place
}
+ w.screen = mouse.screen
w.visible = true
awful.placement.centered(w)
diff --git a/run-shell-3/run-shell.lua b/run-shell-3/run-shell.lua
index 8fab5fd..9bd575b 100644
--- a/run-shell-3/run-shell.lua
+++ b/run-shell-3/run-shell.lua
@@ -34,8 +34,8 @@ function widget.new()
local w = wibox {
visible = false,
ontop = true,
- height = 1060,
- width = 1920
+ height = mouse.screen.geometry.height,
+ width = mouse.screen.geometry.width,
}
w:setup {
diff --git a/spotify-widget/README.md b/spotify-widget/README.md
index 2ae8dfc..3d18559 100644
--- a/spotify-widget/README.md
+++ b/spotify-widget/README.md
@@ -32,7 +32,7 @@ It is possible to customize widget by providing a table with all or some of the
| `dim_when_paused` | `false` | Decrease the widget opacity if spotify is paused |
| `dim_opacity` | `0.2` | Widget's opacity when dimmed, `dim_when_paused` should be set to `true` |
| `max_length` | `15` | Maximum lentgh of artist and title names. Text will be ellipsized if longer. |
-| `show_tooltip` | `true`| Show tooltip on hover with information about the playing song |
+| `show_tooltip` | `true` | Show tooltip on hover with information about the playing song |
| `timeout` | 1 | How often in seconds the widget refreshes |
diff --git a/spotify-widget/spotify.lua b/spotify-widget/spotify.lua
index abd19ef..fb903e8 100644
--- a/spotify-widget/spotify.lua
+++ b/spotify-widget/spotify.lua
@@ -34,7 +34,7 @@ local function worker(args)
local dim_when_paused = args.dim_when_paused == nil and false or args.dim_when_paused
local dim_opacity = args.dim_opacity or 0.2
local max_length = args.max_length or 15
- local show_tooltip = args.show_tooltip == nil and false or args.show_tooltip
+ local show_tooltip = args.show_tooltip == nil and true or args.show_tooltip
local timeout = args.timeout or 1
local cur_artist = ''
@@ -52,31 +52,37 @@ local function worker(args)
widget = wibox.widget.imagebox,
},
{
- id = 'titlew',
- font = font,
- widget = wibox.widget.textbox
+ layout = wibox.container.scroll.horizontal,
+ max_size = 100,
+ step_function = wibox.container.scroll.step_functions.waiting_nonlinear_back_and_forth,
+ speed = 40,
+ {
+ id = 'titlew',
+ font = font,
+ widget = wibox.widget.textbox
+ }
},
layout = wibox.layout.align.horizontal,
set_status = function(self, is_playing)
self.icon.image = (is_playing and play_icon or pause_icon)
if dim_when_paused then
- self.icon.opacity = (is_playing and 1 or dim_opacity)
+ self:get_children_by_id('icon')[1]:set_opacity(is_playing and 1 or dim_opacity)
- self.titlew:set_opacity(is_playing and 1 or dim_opacity)
- self.titlew:emit_signal('widget::redraw_needed')
+ self:get_children_by_id('titlew')[1]:set_opacity(is_playing and 1 or dim_opacity)
+ self:get_children_by_id('titlew')[1]:emit_signal('widget::redraw_needed')
- self.artistw:set_opacity(is_playing and 1 or dim_opacity)
- self.artistw:emit_signal('widget::redraw_needed')
+ self:get_children_by_id('artistw')[1]:set_opacity(is_playing and 1 or dim_opacity)
+ self:get_children_by_id('artistw')[1]:emit_signal('widget::redraw_needed')
end
end,
set_text = function(self, artist, song)
local artist_to_display = ellipsize(artist, max_length)
- if self.artistw.text ~= artist_to_display then
- self.artistw.text = artist_to_display
+ if self:get_children_by_id('artistw')[1]:get_markup() ~= artist_to_display then
+ self:get_children_by_id('artistw')[1]:set_markup(artist_to_display)
end
local title_to_display = ellipsize(song, max_length)
- if self.titlew.text ~= title_to_display then
- self.titlew.text = title_to_display
+ if self:get_children_by_id('titlew')[1]:get_markup() ~= title_to_display then
+ self:get_children_by_id('titlew')[1]:set_markup(title_to_display)
end
end
}
diff --git a/translate-widget/gnome-translate.svg b/translate-widget/gnome-translate.svg
new file mode 100644
index 0000000..ca02b1a
--- /dev/null
+++ b/translate-widget/gnome-translate.svg
@@ -0,0 +1,12 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" version="1">
+ <path style="opacity:0.5" d="M 16,32 32,44 V 20 L 16,4 Z"/>
+ <path style="fill:#e4e4e4" d="M 6,16 C 4.892,16 4,16.892 4,18 V 42 C 4,43.108 4.892,44 6,44 H 32 V 16 Z"/>
+ <path style="opacity:0.2" d="M 15.403,22.554 C 16.003,22.97 16.557,23.478 17.065,24.078 L 16.165,25.186 C 15.611,24.493 15.034,23.916 14.433,23.454 L 15.403,22.554 M 15.403,26.918 C 15.957,27.333 16.488,27.795 16.996,28.303 L 16.096,29.48 C 15.587,28.834 15.033,28.28 14.433,27.818 L 15.402,26.918 M 15.679,31.697 16.788,32.459 C 16.233,34.352 15.425,36.176 14.363,37.931 L 13.185,37.03 C 14.247,35.321 15.079,33.544 15.679,31.697 M 18.934,22 20.25,22.277 C 20.158,22.738 20.019,23.177 19.835,23.593 H 25.237 V 24.839 H 19.281 L 18.657,25.878 C 18.472,26.248 18.172,26.64 17.757,27.056 L 16.925,26.087 C 17.802,25.025 18.472,23.663 18.933,22 M 18.587,26.295 H 24.959 C 24.959,27.726 24.936,29.065 24.89,30.312 H 25.791 V 31.559 H 24.821 C 24.728,32.529 24.659,33.475 24.613,34.399 H 25.652 V 35.576 H 24.475 C 24.29,37.192 23.643,38 22.535,38 22.258,38 21.866,37.954 21.358,37.862 L 21.15,36.684 C 21.75,36.777 22.212,36.823 22.535,36.823 22.858,36.823 23.066,36.407 23.159,35.576 H 17.756 C 17.941,34.329 18.102,32.99 18.241,31.559 H 17.271 V 30.312 H 18.379 C 18.472,29.019 18.541,27.68 18.587,26.295 M 19.626,30.312 H 23.574 C 23.62,29.342 23.643,28.396 23.643,27.472 H 19.834 C 19.788,28.488 19.718,29.435 19.626,30.312 M 21.358,27.819 C 21.866,28.142 22.327,28.511 22.743,28.927 L 21.912,29.966 C 21.496,29.504 21.035,29.088 20.527,28.719 L 21.358,27.818 M 23.297,34.399 C 23.389,33.429 23.459,32.482 23.505,31.559 H 19.557 C 19.465,32.575 19.349,33.521 19.211,34.399 H 23.297 M 21.15,31.905 C 21.704,32.228 22.212,32.598 22.674,33.013 L 21.773,34.052 C 21.312,33.544 20.827,33.106 20.319,32.736 L 21.15,31.905 M 13.877,23.663 V 34.537 H 12.63 V 33.359 H 11.453 V 35.16 H 10.206 V 23.662 H 13.877 M 11.453,32.182 H 12.63 V 24.84 H 11.453 V 32.182"/>
+ <path style="opacity:0.2" d="M 4,42 V 43 C 4,44.108 4.892,45 6,45 H 32 V 44 H 6 C 4.892,44 4,43.108 4,42 Z"/>
+ <path style="fill:#a3a3a3" d="M 16,32 32,44 V 20 L 16,4 Z"/>
+ <path style="opacity:0.2;fill:#ffffff" d="M 6,16 C 4.892,16 4,16.892 4,18 V 19 C 4,17.892 4.892,17 6,17 H 32 V 16 Z"/>
+ <path style="fill:#2095f2" d="M 16,4 V 32 H 42 C 43.108,32 44,31.108 44,30 V 6 C 44,4.892 43.108,4 42,4 Z"/>
+ <path style="fill:#ffffff" d="M 28.221,19.374 28.614,17.902 C 29.055,16.306 29.473,14.441 29.865,12.748 H 29.963 C 30.381,14.417 30.822,16.306 31.264,17.902 L 31.632,19.374 H 28.221 M 33.349,26 H 37.177 L 32.171,10 H 27.828 L 22.821,26 H 26.502 L 27.484,22.196 H 32.367 L 33.349,26"/>
+ <path style="opacity:0.2" d="M 44,30 C 44,31.108 43.108,32 42,32 H 16 V 33 H 42 C 43.108,33 44,32.108 44,31 Z"/>
+ <path style="opacity:0.2;fill:#ffffff" d="M 16,4 V 5 H 42 C 43.108,5 44,5.892 44,7 V 6 C 44,4.892 43.108,4 42,4 Z"/>
+</svg>
diff --git a/translate-widget/translate.lua b/translate-widget/translate.lua
index b333e74..9352ac9 100644
--- a/translate-widget/translate.lua
+++ b/translate-widget/translate.lua
@@ -7,16 +7,17 @@
-------------------------------------------------
local awful = require("awful")
+local spawn = require("awful.spawn")
local capi = {keygrabber = keygrabber }
-local https = require("ssl.https")
+local beautiful = require("beautiful")
local json = require("json")
local naughty = require("naughty")
local wibox = require("wibox")
local gears = require("gears")
local gfs = require("gears.filesystem")
-local BASE_URL = 'https://translate.yandex.net/api/v1.5/tr.json/translate'
-local ICON = '/usr/share/icons/Papirus-Dark/48x48/apps/gnome-translate.svg'
+local TRANSLATE_CMD = [[bash -c 'curl -s -u "apikey:%s" -H "Content-Type: application/json" -d '\''{"text": ["%s"], "model_id":"%s"}'\'' "%s/v3/translate?version=2018-05-01"']]
+local ICON = os.getenv("HOME") .. '/.config/awesome/awesome-wm-widgets/translate-widget/gnome-translate.svg'
--- Returns two values - string to translate and direction:
-- 'dog enfr' -> 'dog', 'en-fr'
@@ -31,88 +32,85 @@ local function extract(input_string)
return word, lang
end
---- Simple url encoder - replaces spaces with '+' sign
--- @param url to encode
-local function urlencode(url)
- if (url) then
- url = string.gsub(url, " ", "+")
- end
- return url
+local function show_warning(message)
+ naughty.notify{
+ preset = naughty.config.presets.critical,
+ title = 'Translate Shell',
+ text = message}
end
-local w = wibox {
- width = 300,
+local w = awful.popup {
+ widget = {},
+ visible = false,
border_width = 1,
+ maximum_width = 400,
+ width = 400,
border_color = '#66ccff',
ontop = true,
- expand = true,
- bg = '#1e252c',
- max_widget_size = 500,
+ bg = beautiful.bg_normal,
shape = function(cr, width, height)
gears.shape.rounded_rect(cr, width, height, 3)
- end
-
+ end,
}
+awful.placement.top(w, { margins = {top = 40}})
-w:setup {
- {
- {
- image = ICON,
- widget = wibox.widget.imagebox,
- resize = false
- },
- id = 'img',
- layout = wibox.container.margin(_, 0, 0, 10)
- },
- {
- {
- id = 'header',
- widget = wibox.widget.textbox
- },
- {
- id = 'src',
- widget = wibox.widget.textbox
- },
- {
- id = 'res',
- widget = wibox.widget.textbox
- },
- id = 'text',
- layout = wibox.layout.fixed.vertical,
- },
- id = 'left',
- layout = wibox.layout.fixed.horizontal
-}
--- Main function - takes the user input and shows the widget with translation
-- @param request_string - user input (dog enfr)
-local function translate(to_translate, lang, api_key)
- local urll = BASE_URL .. '?lang=' .. lang .. '&text=' .. urlencode(to_translate) .. '&key=' .. api_key
-
- local resp_json, code = https.request(urll)
- if (code == 200 and resp_json ~= nil) then
- local resp = json.decode(resp_json).text[1]
-
- w.left.text.header:set_markup('<big>' .. lang .. '</big>')
- w.left.text.src:set_markup('<b>' .. lang:sub(1,2) .. '</b>: <span color="#FFFFFF"> ' .. to_translate .. '</span>')
- w.left.text.res:set_markup('<b>' .. lang:sub(4) .. '</b>: <span color="#FFFFFF"> ' .. resp .. '</span>')
+local function translate(to_translate, lang, api_key, url)
- awful.placement.top(w, { margins = {top = 40}})
-
- local h1 = w.left.text.header:get_height_for_width(w.width, w.screen)
- local h2 = w.left.text.src:get_height_for_width(w.width, w.screen)
- local h3 = w.left.text.res:get_height_for_width(w.width, w.screen)
+ local cmd = string.format(TRANSLATE_CMD, api_key, to_translate, lang, url)
+ spawn.easy_async(cmd, function (stdout, stderr)
+ if stderr ~= '' then
+ show_warning(stderr)
+ end
- -- calculate height of the widget
- w.height = h1 + h2 + h3 + 20
- -- try to vertically align the icon
- w.left.img:set_top((h1 + h2 + h3 + 20 - 48)/2)
+ local resp = json.decode(stdout)
+
+ w:setup {
+ {
+ {
+ {
+ {
+ image = ICON,
+ widget = wibox.widget.imagebox,
+ resize = false
+ },
+ valigh = 'center',
+ layout = wibox.container.place,
+ },
+ {
+ {
+ id = 'src',
+ markup = '<b>' .. lang:sub(1,2) .. '</b>: <span color="#FFFFFF"> ' .. to_translate .. '</span>',
+ widget = wibox.widget.textbox
+ },
+ {
+ id = 'res',
+ markup = '<b>' .. lang:sub(4) .. '</b>: <span color="#FFFFFF"> ' .. resp.translations[1].translation .. '</span>',
+ widget = wibox.widget.textbox
+ },
+ id = 'text',
+ layout = wibox.layout.fixed.vertical,
+ },
+ id = 'left',
+ spacing = 8,
+ layout = wibox.layout.fixed.horizontal
+ },
+ bg = beautiful.bg_normal,
+ forced_width = 400,
+ widget = wibox.container.background
+ },
+ color = beautiful.bg_normal,
+ margins = 8,
+ widget = wibox.container.margin
+ }
w.visible = true
w:buttons(
awful.util.table.join(
awful.button({}, 1, function()
- awful.spawn.with_shell("echo '" .. resp .. "' | xclip -selection clipboard")
+ awful.spawn.with_shell("echo '" .. resp.translations[1].translation .. "' | xclip -selection clipboard")
w.visible = false
end),
awful.button({}, 3, function()
@@ -129,40 +127,46 @@ local function translate(to_translate, lang, api_key)
w.visible = false
end
end)
- else
- naughty.notify({
- preset = naughty.config.presets.critical,
- title = 'Translate Widget Error',
- text = resp_json,
- })
- end
+ end)
end
+local prompt = awful.widget.prompt()
local input_widget = wibox {
+ visible = false,
width = 300,
+ height = 100,
+ maxmimum_width = 300,
+ maxmimum_height = 900,
ontop = true,
screen = mouse.screen,
expand = true,
- bg = '#1e252c',
+ bg = beautiful.bg_normal,
max_widget_size = 500,
border_width = 1,
border_color = '#66ccff',
shape = function(cr, width, height)
gears.shape.rounded_rect(cr, width, height, 3)
- end
+ end,
}
-local prompt = awful.widget.prompt()
-
-input_widget:setup {
- layout = wibox.container.margin,
- prompt,
- left = 10
+input_widget:setup{
+ {
+ prompt,
+ bg = beautiful.bg_normal,
+ widget = wibox.container.background
+ },
+ margins = 8,
+ widget = wibox.container.margin
}
-local function show_translate_prompt(api_key)
+local function launch(args)
+
+ local args = args or {}
+
+ local api_key = args.api_key
+ local url = args.url
+
awful.placement.top(input_widget, { margins = {top = 40}, parent = awful.screen.focused()})
- input_widget.height = 40
input_widget.visible = true
awful.prompt.run {
@@ -181,7 +185,7 @@ local function show_translate_prompt(api_key)
})
return
end
- translate(to_translate, lang, api_key)
+ translate(to_translate, lang, api_key, url)
end,
done_callback = function()
input_widget.visible = false
@@ -190,5 +194,5 @@ local function show_translate_prompt(api_key)
end
return {
- show_translate_prompt = show_translate_prompt
+ launch = launch
}
diff --git a/weather-widget/weather.lua b/weather-widget/weather.lua
index 1465c0c..0317746 100644
--- a/weather-widget/weather.lua
+++ b/weather-widget/weather.lua
@@ -385,7 +385,6 @@ local function worker(args)
hourly_forecast_negative_graph:set_min_value(max_temp < 0 and math.abs(max_temp) * 0.7 or 0)
for i, value in ipairs(values) do
- print(value)
if value >= 0 then
hourly_forecast_graph:add_value(value)
hourly_forecast_negative_graph:add_value(0)