From 099e23aac2372f11a6f2b9a8c0d62bdfd8ee85b6 Mon Sep 17 00:00:00 2001 From: copycat-killer Date: Mon, 23 Jan 2017 20:58:19 +0100 Subject: [PATCH] taskwarrior: asynchronous; #213 enhanced --- ISSUE_TEMPLATE.md | 2 +- icons/redshift/redshift_off.png | Bin 267 -> 0 bytes icons/redshift/redshift_on.png | Bin 253 -> 0 bytes .../{taskwarrior/task.png => taskwarrior.png} | Bin icons/taskwarrior/tasksmall.png | Bin 941 -> 0 bytes widgets/calendar.lua | 25 +-- widgets/contrib/redshift.lua | 4 +- widgets/contrib/task.lua | 173 ++++++------------ widgets/fs.lua | 11 +- wiki | 2 +- 10 files changed, 75 insertions(+), 142 deletions(-) delete mode 100644 icons/redshift/redshift_off.png delete mode 100644 icons/redshift/redshift_on.png rename icons/{taskwarrior/task.png => taskwarrior.png} (100%) delete mode 100755 icons/taskwarrior/tasksmall.png diff --git a/ISSUE_TEMPLATE.md b/ISSUE_TEMPLATE.md index e98373d..e024e8b 100644 --- a/ISSUE_TEMPLATE.md +++ b/ISSUE_TEMPLATE.md @@ -1,4 +1,4 @@ -**Please read the wiki and browse the Issues section first.** +**Please read the [wiki](https://github.com/copycat-killer/lain/wiki) and search the [Issues section](https://github.com/copycat-killer/lain/issues) first.** If you can't find a solution there, then go ahead and provide: diff --git a/icons/redshift/redshift_off.png b/icons/redshift/redshift_off.png deleted file mode 100644 index a92200fcde26a71dafbbc196264e9f3f7b720e93..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 267 zcmeAS@N?(olHy`uVBq!ia0vp^LLkh+1|-AI^@Rf|wj^(N7l!{JxM1({$v_d#0*}aI z1_o|n5N2eUHAey{$X?><>&kwQRhpNT%Pxsc5-22_84^+AoS&PUnpXnkGB7w7r6!i7 zrYMwWmSiZnd-?{X=%um)#q&K~978NlCnrd3YY>cGkaV(skxAK+1zD*Fm+#o(BzpA9 zyT02!JFXZBW^?En?$K+?bSQVsY<>0r64%xLH)7f@yWSAFd^FqV$gZ{tGM*dT_%}?* zGQP+uB)Mm5pkv|050kBXRHR$9TNf{Xaq#t`gX|1Z0mk~9wjY%NxyjSj&t;ucLK6TD C<>&kwQRhpMg;@LNqNkAdl%#er@=ltB<)VvZPmw~~#C^fMp zHASI3vm`^o-P1Q9MK6^dD4yu);uvCaIypgNTZ3Tif~1r6i%iOnEXYbdxO~SJC()x< z-u2z?*>S~4Fq=cqa1YzV%MIRrol%Xx(aj%Nwe&1k?d)g`nce9(;lzWrJzQQqoc22p ndu(#t5oA%-CAUXUs)m8#$W~?T*MDd7fn4F~>gTe~DWM4fyunhR diff --git a/icons/taskwarrior/task.png b/icons/taskwarrior.png similarity index 100% rename from icons/taskwarrior/task.png rename to icons/taskwarrior.png diff --git a/icons/taskwarrior/tasksmall.png b/icons/taskwarrior/tasksmall.png deleted file mode 100755 index 2de6946550635bd442ee57f9b4db65e17168f8d0..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 941 zcmV;e15*5nP)5>B4O(ZlrW$ z&7$Dazd+Z;l~#rLV^K;#3pUO>m!Mz_lDw~rnTez3$Gn+4Ne*0?_wIY=e($^Yob#Qb zBs46>$oY9;V8FkGj=k;nkdO8Q6Q?GW6*YX;CP zUIg?LiH`v;+?N0n00arI0RG~=`+3y>=6T$iWw--iONrNBNyQQG!@aTqvy!as%`*Hg zVROlK`ho0jp4-u`F&N{2JwRm!ULou*+~gkym!CXYw{q8 zAprXUi~!gTU@L%WKo0;u0B~2rqY&I=y;Pnhd8OvB<*!pqBhPc0<>ReBzt}L#$IVP- z-YF3ztV$e<(Jr)e?qam_62~M=x233CIj^-+$4h2*f_!ttx$VWuz@~bo%AWual7NKy zZlxJD<;BBN-^&>D;T7cBs8o4P>dU4&{!v!|k_ydNB>JUnB1SvE1h~s2Zq-!GJ2GQa zay2tG^=xCM(l@iz{M;M{wrz8HQ+GHD;MS5_rYJrSAv{gSV5QP~Xoc^1e|CPkN6Bm` zaV6n_baIOTG@4i}=)071i^MmHgM?ovZpRNL188QW=z^KWZ<7EdaYjN?JyYxO^g|MW z5>Iu5L5Zgm0mS#Ue3^#Dx*yj4b`CHEcT>`_MtsRmn4(Hs< zRq5)ycV~;D*aP74;" - .. awful.util.escape(f:read("*all"):gsub("\n*$", "")) - .. "" - f:close() - - task_notification = naughty.notify({ title = "[task next]", - text = c_text, - icon = task.notify_icon, - position = task.position, - fg = task.fg, - bg = task.bg, - timeout = task.timeout, - screen = scrp - }) + helpers.async(string.format("%s -c '%s'", awful.util.shell, task.cmd), + function(f) + task.notification = naughty.notify({ + preset = task_notification_preset, + title = task.cmd, + text = markup.font(task.notification_preset.font, + awful.util.escape(f:gsub("\n*$", ""))) + }) + end) end -function task.prompt_add() - awful.prompt.run({ prompt = "Add task: " }, - mypromptbox[awful.screen.focused()].widget, - function (...) - local f = io.popen("task add " .. ...) - c_text = "\n" - .. awful.util.escape(f:read("*all")) - .. "" - f:close() - - naughty.notify({ - text = c_text, - icon = task.notify_icon, - position = task.position, - fg = task.fg, - bg = task.bg, - timeout = task.timeout, - }) - end, - nil, - awful.util.getdir("cache") .. "/history_task_add") -end - -function task.prompt_search() - awful.prompt.run({ prompt = "Search task: " }, - mypromptbox[awful.screen.focused()].widget, - function (...) - local f = io.popen("task " .. ...) - c_text = f:read("*all"):gsub(" \n*$", "") - f:close() - - if string.len(c_text) == 0 - then - c_text = "No results found." - else - c_text = "" - .. awful.util.escape(c_text) - .. "" - end - - naughty.notify({ - title = "[task next " .. ... .. "]", - text = c_text, - icon = task.notify_icon, - position = task.position, - fg = task.fg, - bg = task.bg, - timeout = task.timeout, - screen = awful.screen.focused() - }) - end, - nil, - awful.util.getdir("cache") .. "/history_task") +function task.prompt() + awful.prompt.run { + prompt = task.prompt_text, + textbox = awful.screen.focused().mypromptbox.widget, + exe_callback = function(t) + helpers.async(string.format("%s -c '%s'", awful.util.shell, t), + function(f) + naughty.notify { + preset = task_notification_preset, + title = t, + text = markup.font(task.notification_preset.font, + awful.util.escape(f:gsub("\n*$", ""))) + } + end) + end, + history_path = awful.util.getdir("cache") .. "/history_task" + } end function task.attach(widget, args) - local args = args or {} - - task.font_size = tonumber(args.font_size) or 12 - task.font = args.font or beautiful.font:sub(beautiful.font:find(""), - findLast(beautiful.font, " ")) - task.fg = args.fg or beautiful.fg_normal or "#FFFFFF" - task.bg = args.bg or beautiful.bg_normal or "#FFFFFF" - task.position = args.position or "top_right" - task.timeout = args.timeout or 7 - task.scr_pos = args.scr_pos or 1 - task.followtag = args.followtag or false - task.cmdline = args.cmdline or "next" - - task.notify_icon = icons_dir .. "/taskwarrior/task.png" - task.notify_icon_small = icons_dir .. "/taskwarrior/tasksmall.png" + local args = args or {} + task.show_cmd = args.cmd or "task" + task.prompt_text = args.prompt_text or "Enter task command: " + task.followtag = args.followtag or false + task.notification_preset = args.notification_preset + + if not task.notification_preset then + task.notification_preset = naughty.config.defaults + task.notification_preset.font = "Monospace 10" + task.notification_preset.icon = helpers.icons_dir .. "/taskwarrior.png" + end - widget:connect_signal("mouse::enter", function () task.show(task.scr_pos) end) - widget:connect_signal("mouse::leave", function () task.hide() end) + if widget then + widget:connect_signal("mouse::enter", function () task.show() end) + widget:connect_signal("mouse::leave", function () task.hide() end) + end end -return setmetatable(task, { __call = function(_, ...) return create(...) end }) +return task diff --git a/widgets/fs.lua b/widgets/fs.lua index 391c260..3a97d4c 100644 --- a/widgets/fs.lua +++ b/widgets/fs.lua @@ -37,7 +37,7 @@ function fs.show(seconds, scr) if fs.followtag then fs.notification_preset.screen = focused() elseif scr then - fs.notification_preset.screen = scr + fs.notification_preset.screen = scr or 1 end local cmd = (fs.options and string.format("dfs %s", fs.options)) or "dfs" @@ -74,7 +74,6 @@ local function worker(args) helpers.set_map(partition, false) - function update() fs_info, fs_now = {}, {} helpers.async(string.format("%s -c 'LC_ALL=C df -k --output=target,size,used,avail,pcent'", shell), function(f) @@ -107,11 +106,9 @@ local function worker(args) if notify == "on" and tonumber(fs_now.used) >= 99 and not helpers.get_map(partition) then naughty.notify({ - title = "Warning", - text = partition .. " is empty!", - timeout = 8, - fg = "#000000", - bg = "#FFFFFF" + preset = naughty.config.presets.critical, + title = "Warning", + text = partition .. " is empty", }) helpers.set_map(partition, true) else diff --git a/wiki b/wiki index 66836bb..2f7c2a9 160000 --- a/wiki +++ b/wiki @@ -1 +1 @@ -Subproject commit 66836bbf1ffc0dd3bd3aef4799fff78ded9df4ec +Subproject commit 2f7c2a96a29a94829acf0b9e7fb614a7432a5092 -- 2.39.5