From 9e8081d4f12f64903c59de70b541737e811642b3 Mon Sep 17 00:00:00 2001 From: Peter Palfrader Date: Mon, 25 Jun 2018 09:39:04 +0200 Subject: awesome update --- config/awesome/countdown.lua | 78 +++++++++++++++++++++++++++++++++++++++++ config/awesome/rc.lua | 8 +++++ config/awesome/weasel-rules.lua | 10 ++++-- 3 files changed, 93 insertions(+), 3 deletions(-) create mode 100644 config/awesome/countdown.lua (limited to 'config') diff --git a/config/awesome/countdown.lua b/config/awesome/countdown.lua new file mode 100644 index 0000000..92d2c99 --- /dev/null +++ b/config/awesome/countdown.lua @@ -0,0 +1,78 @@ +-- from https://awesomewm.org/recipes/countdown/ +-- on 2018-04-10 +-- slightly modified + +local gears = require("gears") +local awful = require("awful") +local wibox = require("wibox") +local naughty = require("naughty") +local beautiful = require("beautiful") + +countdown = { + widget = wibox.widget.textbox(), + checkbox = wibox.widget { + checked = false, + check_color = "#ff0000", -- customize + border_color = beautiful.fg_normal, -- customize + border_width = 2, -- customize + shape = gears.shape.circle, + widget = wibox.widget.checkbox + } +} + +function countdown.set() + awful.prompt.run { + prompt = "Countdown minutes: ", -- floats accepted + textbox = awful.screen.focused().mypromptbox.widget, + exe_callback = function(timeout) + if countdown.timer and countdown.timer.started then + countdown.seconds = tonumber(timeout) * 60 + return + end + + countdown.seconds = tonumber(timeout) + if not countdown.seconds then return end + countdown.checkbox.checked = false + countdown.minute_t = countdown.seconds > 1 and "minutes" or "minute" + countdown.seconds = countdown.seconds * 60 + countdown.timer = gears.timer({ timeout = 1 }) + countdown.timer:connect_signal("timeout", function() + if countdown.seconds > 0 then + local minutes = math.floor(countdown.seconds / 60) + local seconds = math.fmod(countdown.seconds, 60) + countdown.widget:set_markup(string.format("%d:%02d", minutes, seconds)) + countdown.seconds = countdown.seconds - 1 + else + naughty.notify({ + preset = naughty.config.presets.critical, + title = "Countdown", + text = string.format("%s %s timeout", timeout, countdown.minute_t), + timeout = 30, + position = "top_middle", + run = function(notification) + countdown.widget:set_markup("") + countdown.checkbox.checked = false + notification.die(naughty.notificationClosedReason.dismissedByUser) + end + }) + countdown.widget:set_markup("") + countdown.checkbox.checked = true + countdown.timer:stop() + end + end) + countdown.timer:start() + end + } +end + +countdown.checkbox:buttons(awful.util.table.join( + awful.button({}, 1, function() countdown.set() end), -- left click + awful.button({}, 3, function() -- right click + if countdown.timer and countdown.timer.started then + countdown.timer:stop() + naughty.notify({ title = "Countdown", text = "Timer stopped" }) + end + countdown.widget:set_markup("") + countdown.checkbox.checked = false + end) +)) diff --git a/config/awesome/rc.lua b/config/awesome/rc.lua index bbc4eea..4e07d75 100644 --- a/config/awesome/rc.lua +++ b/config/awesome/rc.lua @@ -18,6 +18,7 @@ require("debian.menu") require("volume") require("battery") require("weasel-rules") +require("countdown") -- require("revelation") -- {{{ Error handling @@ -208,6 +209,8 @@ awful.screen.connect_for_each_screen(function(s) right_layout:add(wibox.widget.systray()) right_layout:add(battery_widget) right_layout:add(volume_widget) + right_layout:add(countdown.widget) + right_layout:add(countdown.checkbox) right_layout:add(mytextclock) right_layout:add(s.mylayoutbox) @@ -345,6 +348,11 @@ globalkeys = awful.util.table.join( awful.key({ modkey, "Shift" }, "m", function () awful.util.spawn_with_shell("xterm-mail-cosy") end), awful.key({ modkey }, "i", function () awful.util.spawn_with_shell("xterm-irc") end), + -- awful.key({ modkey }, "k", function () awful.util.spawn_with_shell("keepassx") end), + awful.key({ modkey }, "c", function () awful.util.spawn_with_shell("ch") end), + awful.key({ modkey }, "f", function () awful.util.spawn_with_shell("ff") end), + awful.key({ modkey }, "s", function () awful.util.spawn_with_shell("signal") end), + -- awful.key({ "Control", "Mod1"}, "End", function () awful.util.spawn_with_shell("xscreensaver-command -lock; sleep 1; systemctl suspend") end), --awful.key({ "Control", "Mod1"}, "l", function () awful.util.spawn_with_shell("xscreensaver-command -lock") end), diff --git a/config/awesome/weasel-rules.lua b/config/awesome/weasel-rules.lua index 7da4fc2..4fd2821 100644 --- a/config/awesome/weasel-rules.lua +++ b/config/awesome/weasel-rules.lua @@ -37,10 +37,14 @@ function get_weasel_rules() { rule = { class = "URxvt" , name = "Mail COSY" }, properties = { screen = im_screen, tag = '11' } }, - { rule = { class = "Chromium" , name = "Signal Private Messenger" }, - properties = { screen = im_screen, tag = '21' } }, - { rule = { class = "Chromium" , name = "Signal" }, + -- { rule = { class = "Chromium" , name = "Signal Private Messenger" }, + -- properties = { screen = im_screen, tag = '21' } }, + -- { rule = { class = "Chromium" , name = "Signal" }, + -- properties = { screen = im_screen, tag = '21' } }, + { rule = { class = "Signal" , name = "Signal" }, properties = { screen = im_screen, tag = '21' } }, + { rule = { class = "Keepassx" , name = "KeePassX" }, + properties = { screen = im_screen, tag = '22' } }, --{ rule = { maximized_horizontal = true }, -- these two should remove window borders from maximized windows because they get in the way -- properties = { border_width = 0 } }, -- cgit v1.2.3