diff options
39 files changed, 802 insertions, 158 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/icons/audio-volume-high-symbolic.svg b/experiments/volume/icons/audio-volume-high-symbolic.svg new file mode 100644 index 0000000..985c107 --- /dev/null +++ b/experiments/volume/icons/audio-volume-high-symbolic.svg @@ -0,0 +1,88 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<svg + xmlns:dc="http://purl.org/dc/elements/1.1/" + xmlns:cc="http://creativecommons.org/ns#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns="http://www.w3.org/2000/svg" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + width="16" + viewBox="0 0 16 16" + height="16" + id="svg2" + version="1.1" + inkscape:version="0.91 r" + sodipodi:docname="audio-volume-high-symbolic.svg"> + <metadata + id="metadata30"> + <rdf:RDF> + <cc:Work + rdf:about=""> + <dc:format>image/svg+xml</dc:format> + <dc:type + rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> + <dc:title></dc:title> + </cc:Work> + </rdf:RDF> + </metadata> + <sodipodi:namedview + pagecolor="#ffffff" + bordercolor="#666666" + borderopacity="1" + objecttolerance="10" + gridtolerance="10" + guidetolerance="10" + inkscape:pageopacity="0" + inkscape:pageshadow="2" + inkscape:window-width="1215" + inkscape:window-height="776" + id="namedview28" + showgrid="true" + inkscape:zoom="38.125" + inkscape:cx="8" + inkscape:cy="8" + inkscape:window-x="65" + inkscape:window-y="24" + inkscape:window-maximized="1" + inkscape:current-layer="svg2" + showguides="true" + inkscape:snap-intersection-paths="false" + inkscape:object-paths="false"> + <inkscape:grid + type="xygrid" + id="grid4158" /> + </sodipodi:namedview> + <defs + id="defs4" /> + <path + d="M 6,2 2,6 2,10 6,14 6,9 7,8 6,7 Z" + id="path18" + inkscape:connector-curvature="0" + style="fill:#bebebe" + sodipodi:nodetypes="cccccccc" /> + <path + d="M 1.300003,5 C 0.216589,5 0,6.163269 0,7.4 L 0,8.6 C 0,9.836747 0.24312,11 1.300003,11 L 3,11 3,5 Z" + id="path20" + inkscape:connector-curvature="0" + style="fill:#bebebe" + sodipodi:nodetypes="ssssccs" /> + <path + style="opacity:1;fill:#bebebe;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" + d="M 13.140638,1 11.726417,2.413582 C 12.808349,3.4955144 13.990412,5.4467621 14,8 c 0,2.551493 -1.192916,4.505751 -2.273583,5.586418 L 13.140638,15 C 14.595711,13.544927 16.019176,11 16,8 16.035061,5 14.595117,2.4544787 13.140638,1 Z" + id="path4508" + inkscape:connector-curvature="0" + sodipodi:nodetypes="ccccccc" /> + <path + style="opacity:1;fill:#bebebe;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" + d="M 11,3.1156678 9.5897193,4.5261118 C 10.372347,5.3087395 11,6.5690611 11,8 11,9.4309388 10.372767,10.690952 9.5897193,11.474 L 11,12.884 C 12.275645,11.608355 13,9.854095 13,8 13,6.1543677 12.273068,4.3887355 11,3.1156678 Z" + id="path4529" + inkscape:connector-curvature="0" + sodipodi:nodetypes="ccccccc" /> + <path + style="opacity:1;fill:#bebebe;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" + d="M 8.629,5 7.2094668,6.4096296 C 8,7.05621 8,7.805653 8,8 8,8.1932576 7.982199,8.9408674 7.209,9.59 L 8.6289063,11 C 9.8466375,9.952694 10,8.5984701 10,8 10,7.400497 9.854476,6.062891 8.629,5 Z" + id="path4569" + inkscape:connector-curvature="0" + sodipodi:nodetypes="ccscccc" /> +</svg> diff --git a/experiments/volume/icons/audio-volume-low-symbolic.svg b/experiments/volume/icons/audio-volume-low-symbolic.svg new file mode 100644 index 0000000..7eb4531 --- /dev/null +++ b/experiments/volume/icons/audio-volume-low-symbolic.svg @@ -0,0 +1,88 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<svg + xmlns:dc="http://purl.org/dc/elements/1.1/" + xmlns:cc="http://creativecommons.org/ns#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns="http://www.w3.org/2000/svg" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + width="16" + viewBox="0 0 16 16" + height="16" + id="svg2" + version="1.1" + inkscape:version="0.91 r" + sodipodi:docname="audio-volume-low-symbolic.svg"> + <metadata + id="metadata30"> + <rdf:RDF> + <cc:Work + rdf:about=""> + <dc:format>image/svg+xml</dc:format> + <dc:type + rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> + <dc:title></dc:title> + </cc:Work> + </rdf:RDF> + </metadata> + <sodipodi:namedview + pagecolor="#ffffff" + bordercolor="#666666" + borderopacity="1" + objecttolerance="10" + gridtolerance="10" + guidetolerance="10" + inkscape:pageopacity="0" + inkscape:pageshadow="2" + inkscape:window-width="1215" + inkscape:window-height="776" + id="namedview28" + showgrid="true" + inkscape:zoom="38.125" + inkscape:cx="8" + inkscape:cy="8" + inkscape:window-x="65" + inkscape:window-y="24" + inkscape:window-maximized="1" + inkscape:current-layer="svg2" + showguides="true" + inkscape:snap-intersection-paths="false" + inkscape:object-paths="false"> + <inkscape:grid + type="xygrid" + id="grid4158" /> + </sodipodi:namedview> + <defs + id="defs4" /> + <path + d="M 6,2 2,6 2,10 6,14 6,9 7,8 6,7 Z" + id="path18" + inkscape:connector-curvature="0" + style="fill:#bebebe" + sodipodi:nodetypes="cccccccc" /> + <path + d="M 1.300003,5 C 0.216589,5 0,6.163269 0,7.4 L 0,8.6 C 0,9.836747 0.24312,11 1.300003,11 L 3,11 3,5 Z" + id="path20" + inkscape:connector-curvature="0" + style="fill:#bebebe" + sodipodi:nodetypes="ssssccs" /> + <path + style="opacity:0.3;fill:#bebebe;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" + d="M 13.140638,1 11.726417,2.413582 C 12.808349,3.4955144 13.990412,5.4467621 14,8 c 0,2.551493 -1.192916,4.505751 -2.273583,5.586418 L 13.140638,15 C 14.595711,13.544927 16.019176,11 16,8 16.035061,5 14.595117,2.4544787 13.140638,1 Z" + id="path4508" + inkscape:connector-curvature="0" + sodipodi:nodetypes="ccccccc" /> + <path + style="opacity:0.3;fill:#bebebe;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" + d="M 11,3.1156678 9.5897193,4.5261118 C 10.372347,5.3087395 11,6.5690611 11,8 11,9.4309388 10.372767,10.690952 9.5897193,11.474 L 11,12.884 C 12.275645,11.608355 13,9.854095 13,8 13,6.1543677 12.273068,4.3887355 11,3.1156678 Z" + id="path4529" + inkscape:connector-curvature="0" + sodipodi:nodetypes="ccccccc" /> + <path + style="opacity:1;fill:#bebebe;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" + d="M 8.629,5 7.2094668,6.4096296 C 8,7.05621 8,7.805653 8,8 8,8.1932576 7.982199,8.9408674 7.209,9.59 L 8.6289063,11 C 9.8466375,9.952694 10,8.5984701 10,8 10,7.400497 9.854476,6.062891 8.629,5 Z" + id="path4569" + inkscape:connector-curvature="0" + sodipodi:nodetypes="ccscccc" /> +</svg> diff --git a/experiments/volume/icons/audio-volume-medium-symbolic.svg b/experiments/volume/icons/audio-volume-medium-symbolic.svg new file mode 100644 index 0000000..11e44fe --- /dev/null +++ b/experiments/volume/icons/audio-volume-medium-symbolic.svg @@ -0,0 +1,88 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<svg + xmlns:dc="http://purl.org/dc/elements/1.1/" + xmlns:cc="http://creativecommons.org/ns#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns="http://www.w3.org/2000/svg" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + width="16" + viewBox="0 0 16 16" + height="16" + id="svg2" + version="1.1" + inkscape:version="0.91 r" + sodipodi:docname="audio-volume-medium-symbolic.svg"> + <metadata + id="metadata30"> + <rdf:RDF> + <cc:Work + rdf:about=""> + <dc:format>image/svg+xml</dc:format> + <dc:type + rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> + <dc:title></dc:title> + </cc:Work> + </rdf:RDF> + </metadata> + <sodipodi:namedview + pagecolor="#ffffff" + bordercolor="#666666" + borderopacity="1" + objecttolerance="10" + gridtolerance="10" + guidetolerance="10" + inkscape:pageopacity="0" + inkscape:pageshadow="2" + inkscape:window-width="1215" + inkscape:window-height="776" + id="namedview28" + showgrid="true" + inkscape:zoom="38.125" + inkscape:cx="8" + inkscape:cy="8" + inkscape:window-x="65" + inkscape:window-y="24" + inkscape:window-maximized="1" + inkscape:current-layer="svg2" + showguides="true" + inkscape:snap-intersection-paths="false" + inkscape:object-paths="false"> + <inkscape:grid + type="xygrid" + id="grid4158" /> + </sodipodi:namedview> + <defs + id="defs4" /> + <path + d="M 6,2 2,6 2,10 6,14 6,9 7,8 6,7 Z" + id="path18" + inkscape:connector-curvature="0" + style="fill:#bebebe" + sodipodi:nodetypes="cccccccc" /> + <path + d="M 1.300003,5 C 0.216589,5 0,6.163269 0,7.4 L 0,8.6 C 0,9.836747 0.24312,11 1.300003,11 L 3,11 3,5 Z" + id="path20" + inkscape:connector-curvature="0" + style="fill:#bebebe" + sodipodi:nodetypes="ssssccs" /> + <path + style="opacity:0.3;fill:#bebebe;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" + d="M 13.140638,1 11.726417,2.413582 C 12.808349,3.4955144 13.990412,5.4467621 14,8 c 0,2.551493 -1.192916,4.505751 -2.273583,5.586418 L 13.140638,15 C 14.595711,13.544927 16.019176,11 16,8 16.035061,5 14.595117,2.4544787 13.140638,1 Z" + id="path4508" + inkscape:connector-curvature="0" + sodipodi:nodetypes="ccccccc" /> + <path + style="opacity:1;fill:#bebebe;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" + d="M 11,3.1156678 9.5897193,4.5261118 C 10.372347,5.3087395 11,6.5690611 11,8 11,9.4309388 10.372767,10.690952 9.5897193,11.474 L 11,12.884 C 12.275645,11.608355 13,9.854095 13,8 13,6.1543677 12.273068,4.3887355 11,3.1156678 Z" + id="path4529" + inkscape:connector-curvature="0" + sodipodi:nodetypes="ccccccc" /> + <path + style="opacity:1;fill:#bebebe;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" + d="M 8.629,5 7.2094668,6.4096296 C 8,7.05621 8,7.805653 8,8 8,8.1932576 7.982199,8.9408674 7.209,9.59 L 8.6289063,11 C 9.8466375,9.952694 10,8.5984701 10,8 10,7.400497 9.854476,6.062891 8.629,5 Z" + id="path4569" + inkscape:connector-curvature="0" + sodipodi:nodetypes="ccscccc" /> +</svg> diff --git a/experiments/volume/icons/audio-volume-muted-symbolic.svg b/experiments/volume/icons/audio-volume-muted-symbolic.svg new file mode 100644 index 0000000..e577d05 --- /dev/null +++ b/experiments/volume/icons/audio-volume-muted-symbolic.svg @@ -0,0 +1,88 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<svg + xmlns:dc="http://purl.org/dc/elements/1.1/" + xmlns:cc="http://creativecommons.org/ns#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns="http://www.w3.org/2000/svg" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + width="16" + viewBox="0 0 16 16" + height="16" + id="svg2" + version="1.1" + inkscape:version="0.91 r13725" + sodipodi:docname="audio-volume-muted-symbolic.svg"> + <metadata + id="metadata30"> + <rdf:RDF> + <cc:Work + rdf:about=""> + <dc:format>image/svg+xml</dc:format> + <dc:type + rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> + <dc:title></dc:title> + </cc:Work> + </rdf:RDF> + </metadata> + <sodipodi:namedview + pagecolor="#ffffff" + bordercolor="#666666" + borderopacity="1" + objecttolerance="10" + gridtolerance="10" + guidetolerance="10" + inkscape:pageopacity="0" + inkscape:pageshadow="2" + inkscape:window-width="1215" + inkscape:window-height="776" + id="namedview28" + showgrid="true" + inkscape:zoom="38.125" + inkscape:cx="3.4229508" + inkscape:cy="7.947541" + inkscape:window-x="65" + inkscape:window-y="24" + inkscape:window-maximized="1" + inkscape:current-layer="svg2" + showguides="true" + inkscape:snap-intersection-paths="false" + inkscape:object-paths="false"> + <inkscape:grid + type="xygrid" + id="grid4158" /> + </sodipodi:namedview> + <defs + id="defs4" /> + <path + d="M 6,2 2,6 2,10 6,14 6,9 7,8 6,7 Z" + id="path18" + inkscape:connector-curvature="0" + style="fill:#bebebe" + sodipodi:nodetypes="cccccccc" /> + <path + d="M 1.300003,5 C 0.216589,5 0,6.163269 0,7.4 L 0,8.6 C 0,9.836747 0.24312,11 1.300003,11 L 3,11 3,5 Z" + id="path20" + inkscape:connector-curvature="0" + style="fill:#bebebe" + sodipodi:nodetypes="ssssccs" /> + <path + style="opacity:0.3;fill:#bebebe;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" + d="M 13.140638,1 11.726417,2.413582 C 12.808349,3.4955144 13.990412,5.4467621 14,8 c 0,2.551493 -1.192916,4.505751 -2.273583,5.586418 L 13.140638,15 C 14.595711,13.544927 16.019176,11 16,8 16.035061,5 14.595117,2.4544787 13.140638,1 Z" + id="path4508" + inkscape:connector-curvature="0" + sodipodi:nodetypes="ccccccc" /> + <path + style="opacity:0.3;fill:#bebebe;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" + d="M 11,3.1156678 9.5897193,4.5261118 C 10.372347,5.3087395 11,6.5690611 11,8 11,9.4309388 10.372767,10.690952 9.5897193,11.474 L 11,12.884 C 12.275645,11.608355 13,9.854095 13,8 13,6.1543677 12.273068,4.3887355 11,3.1156678 Z" + id="path4529" + inkscape:connector-curvature="0" + sodipodi:nodetypes="ccccccc" /> + <path + style="opacity:0.3;fill:#bebebe;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" + d="M 8.629,5 7.2094668,6.4096296 C 8,7.05621 8,7.805653 8,8 8,8.1932576 7.982199,8.9408674 7.209,9.59 L 8.6289063,11 C 9.8466375,9.952694 10,8.5984701 10,8 10,7.400497 9.854476,6.062891 8.629,5 Z" + id="path4569" + inkscape:connector-curvature="0" + sodipodi:nodetypes="ccscccc" /> +</svg> 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 beaa119..9110a45 100644 --- a/experiments/volume/volume.lua +++ b/experiments/volume/volume.lua @@ -12,39 +12,26 @@ local wibox = require("wibox") local spawn = require("awful.spawn") local gears = require("gears") local beautiful = require("beautiful") +local watch = require("awful.widget.watch") local utils = require("awesome-wm-widgets.experiments.volume.utils") -local HOME_DIR = os.getenv("HOME") -local WIDGET_DIR = HOME_DIR .. '/.config/awesome/awesome-wm-widgets/experiments/volume' local LIST_DEVICES_CMD = [[sh -c "pacmd list-sinks; pacmd list-sources"]] +local GET_VOLUME_CMD = 'amixer -D pulse sget Master' +local INC_VOLUME_CMD = 'amixer -q -D pulse sset Master 5%+' +local DEC_VOLUME_CMD = 'amixer -q -D pulse sset Master 5%-' +local TOG_VOLUME_CMD = 'amixer -q -D pulse sset Master toggle' -local rows = { layout = wibox.layout.fixed.vertical } -local volume_widget = wibox.widget { - { - { - id = "icon", - image = WIDGET_DIR .. '/volume-2.svg', - widget = wibox.widget.imagebox - }, - id = "margin", - margins = 4, - layout = wibox.container.margin - }, - { - id = "txt", - widget = wibox.widget.textbox - }, - layout = wibox.layout.fixed.horizontal, - set_text = function(self, new_value) - self.txt.text = new_value - end, - set_icon = function(self, new_value) - self.margin.icon.image = new_value - end +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 } local popup = awful.popup{ bg = beautiful.bg_normal, @@ -60,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 @@ -82,7 +69,6 @@ local function build_rows(devices, on_checkbox_click, device_type) } checkbox:connect_signal("button::press", function(c) - print(string.format([[sh -c 'pacmd set-default-%s "%s"']], device_type, device.name)) spawn.easy_async(string.format([[sh -c 'pacmd set-default-%s "%s"']], device_type, device.name), function() on_checkbox_click() end) @@ -108,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 @@ -147,25 +155,49 @@ local function rebuild_popup() popup:setup(rows) end) - end local function worker(args) + 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( - awful.button({}, 1, function() + awful.button({}, 3, function() if popup.visible then popup.visible = not popup.visible else rebuild_popup() popup:move_next_to(mouse.current_widget_geometry) end - end) + end), + awful.button({}, 4, function() awful.spawn(INC_VOLUME_CMD, false) end), + awful.button({}, 5, function() awful.spawn(DEC_VOLUME_CMD, false) end), + awful.button({}, 1, function() awful.spawn(TOG_VOLUME_CMD, false) end) ) ) + local function update_graphic(widget, stdout) + local mute = string.match(stdout, "%[(o%D%D?)%]") -- \[(o\D\D?)\] - [on] or [off] + if mute == 'off' then volume_widget:mute() + elseif mute == 'on' then volume_widget:unmute() + end + local volume = string.match(stdout, "(%d?%d?%d)%%") -- (\d?\d?\d)\%) + volume = string.format("% 3d", volume) + widget:set_volume_level(volume) + end + + watch(GET_VOLUME_CMD, 1, update_graphic, volume_widget) + return volume_widget end diff --git a/experiments/volume/widgets/arc-widget.lua b/experiments/volume/widgets/arc-widget.lua new file mode 100644 index 0000000..d7a3b1f --- /dev/null +++ b/experiments/volume/widgets/arc-widget.lua @@ -0,0 +1,39 @@ +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() + + return wibox.widget { + { + id = "icon", + image = ICON_DIR .. 'audio-volume-high-symbolic.svg', + resize = true, + widget = wibox.widget.imagebox, + }, + max_value = 100, + thickness = 2, + start_angle = 4.71238898, -- 2pi*3/4 + forced_height = 18, + forced_width = 18, + bg = '#ffffff11', + paddings = 2, + widget = wibox.container.arcchart, + set_volume_level = function(self, new_value) + self.value = new_value + end, + mute = function(self) + self.colors = {'#BF616A'} + end, + unmute = function(self) + self.colors = {beautiful.fg_color} + end + } + +end + + +return widget
\ No newline at end of file diff --git a/experiments/volume/widgets/icon-and-text-widget.lua b/experiments/volume/widgets/icon-and-text-widget.lua new file mode 100644 index 0000000..5ea626b --- /dev/null +++ b/experiments/volume/widgets/icon-and-text-widget.lua @@ -0,0 +1,45 @@ +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 + }, + { + id = 'txt', + widget = wibox.widget.textbox + }, + layout = wibox.layout.fixed.horizontal, + 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" + else + volume_icon_name="audio-volume-high-symbolic" + 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, + + } + +end + + +return widget
\ No newline at end of file diff --git a/experiments/volume/widgets/icon-widget.lua b/experiments/volume/widgets/icon-widget.lua new file mode 100644 index 0000000..6725e6d --- /dev/null +++ b/experiments/volume/widgets/icon-widget.lua @@ -0,0 +1,35 @@ +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 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" + else + volume_icon_name="audio-volume-high-symbolic" + 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, + } + +end + +return widget
\ No newline at end of file diff --git a/fs-widget/README.md b/fs-widget/README.md index 48d2ffe..5cda048 100644 --- a/fs-widget/README.md +++ b/fs-widget/README.md @@ -1,20 +1,20 @@ -# Storage Widget +# Filesystem Widget This widget shows disk usage. When clicked another widget appears with more detailed information. By default it monitors the "/" mount. It can be configured with a list of mounts to monitor though only the first will show in the wibar. To have -multiple mounts displayed on the wibar simply define multiple `storage_widgets` +multiple mounts displayed on the wibar simply define multiple `fs_widgets` with different mounts as arguments. ```lua - local storage_widget = require("awesome-wm-widgets.storage-widget.storage-widget") + local fs_widget = require("awesome-wm-widgets.fs-widget.fs-widget") ... s.mywibox:setup { s.mytasklist, -- Middle widget { -- Right widgets - storage_widget(), --default + fs_widget(), --default wibox.widget.textbox(':'), - storage_widget({ mounts = { '/', '/mnt/musicj' } }), -- multiple mounts + fs_widget({ mounts = { '/', '/mnt/musicj' } }), -- multiple mounts ... ``` 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 Binary files differnew file mode 100644 index 0000000..b31245b --- /dev/null +++ b/github-contributions-widget/screenshots/Thomashighbaugh.png diff --git a/github-contributions-widget/screenshots/classic.png b/github-contributions-widget/screenshots/classic.png Binary files differnew file mode 100644 index 0000000..4652140 --- /dev/null +++ b/github-contributions-widget/screenshots/classic.png diff --git a/github-contributions-widget/screenshots/dracula.png b/github-contributions-widget/screenshots/dracula.png Binary files differnew file mode 100644 index 0000000..65fb769 --- /dev/null +++ b/github-contributions-widget/screenshots/dracula.png diff --git a/github-contributions-widget/screenshots/leftpad.png b/github-contributions-widget/screenshots/leftpad.png Binary files differnew file mode 100644 index 0000000..19e4f64 --- /dev/null +++ b/github-contributions-widget/screenshots/leftpad.png diff --git a/github-contributions-widget/screenshots/pink.png b/github-contributions-widget/screenshots/pink.png Binary files differnew file mode 100644 index 0000000..2fb7bc6 --- /dev/null +++ b/github-contributions-widget/screenshots/pink.png diff --git a/github-contributions-widget/screenshot.jpg b/github-contributions-widget/screenshots/screenshot.jpg Binary files differindex 15ad456..15ad456 100644 --- a/github-contributions-widget/screenshot.jpg +++ b/github-contributions-widget/screenshots/screenshot.jpg diff --git a/github-contributions-widget/screenshot1.jpg b/github-contributions-widget/screenshots/screenshot1.jpg Binary files differindex d1eeb44..d1eeb44 100644 --- a/github-contributions-widget/screenshot1.jpg +++ b/github-contributions-widget/screenshots/screenshot1.jpg diff --git a/github-contributions-widget/screenshot2.jpg b/github-contributions-widget/screenshots/screenshot2.jpg Binary files differindex 5ce47f2..5ce47f2 100644 --- a/github-contributions-widget/screenshot2.jpg +++ b/github-contributions-widget/screenshots/screenshot2.jpg diff --git a/github-contributions-widget/screenshots/standard.png b/github-contributions-widget/screenshots/standard.png Binary files differnew file mode 100644 index 0000000..e10479a --- /dev/null +++ b/github-contributions-widget/screenshots/standard.png diff --git a/github-contributions-widget/screenshots/teal.png b/github-contributions-widget/screenshots/teal.png Binary files differnew file mode 100644 index 0000000..f10de7a --- /dev/null +++ b/github-contributions-widget/screenshots/teal.png 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/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/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) |