]> git.madduck.net Git - etc/awesome.git/commitdiff

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

Merge pull request #377 from sim590/menu-iterator
authorLuca CPZ <1777696+lcpz@users.noreply.github.com>
Sat, 17 Feb 2018 11:19:53 +0000 (12:19 +0100)
committerGitHub <noreply@github.com>
Sat, 17 Feb 2018 11:19:53 +0000 (12:19 +0100)
menu_iterator: naughty.notify based menu utility

30 files changed:
helpers.lua
init.lua
layout/cascade.lua
layout/centerwork.lua
layout/init.lua
layout/termfair.lua
scripts/dfs [deleted file]
util/init.lua
util/markup.lua
util/quake.lua
util/separators.lua
widget/alsa.lua
widget/alsabar.lua
widget/bat.lua
widget/calendar.lua
widget/contrib/init.lua
widget/contrib/tpbat/init.lua
widget/cpu.lua
widget/fs.lua
widget/imap.lua
widget/init.lua
widget/mem.lua
widget/mpd.lua
widget/net.lua
widget/pulse.lua
widget/pulsebar.lua
widget/sysload.lua
widget/temp.lua
widget/weather.lua
wiki

index ce655761405b9a972b58cda4e0e8552052b1daee..313579f8a3d28368b4918faf5e0a32f4b9ca9e37 100644 (file)
@@ -1,11 +1,11 @@
 --[[
 
      Licensed under GNU General Public License v2
-      * (c) 2013, Luke Bonham
+      * (c) 2013, Luca CPZ
 
 --]]
 
-local spawn = require("awful.spawn")
+local spawn      = require("awful.spawn")
 local timer      = require("gears.timer")
 local debug      = require("debug")
 local io         = { lines = io.lines,
@@ -112,7 +112,7 @@ end
 function helpers.async(cmd, callback)
     return spawn.easy_async(cmd,
     function (stdout, stderr, reason, exit_code)
-        callback(stdout)
+        callback(stdout, exit_code)
     end)
 end
 
@@ -120,10 +120,19 @@ end
 function helpers.async_with_shell(cmd, callback)
     return spawn.easy_async_with_shell(cmd,
     function (stdout, stderr, reason, exit_code)
-        callback(stdout)
+        callback(stdout, exit_code)
     end)
 end
 
+-- run a command and execute a function on its output line by line
+function helpers.line_callback(cmd, callback)
+    return spawn.with_line_callback(cmd, {
+        stdout = function (line)
+            callback(line)
+        end,
+    })
+end
+
 -- }}}
 
 -- {{{ A map utility
index 46c7659cd65a550e03cb3cf7efbb5c48bea972f4..b59d5dd93bb9568c83e80874f6a45a719d3ef54e 100644 (file)
--- a/init.lua
+++ b/init.lua
@@ -4,7 +4,7 @@
      Layouts, widgets and utilities for Awesome WM
 
      Licensed under GNU General Public License v2
-      * (c) 2013, Luke Bonham
+      * (c) 2013, Luca CPZ
 
 --]]
 
index f7dffb927514e61c181a9941974ed38911a568d3..cbc3877b0fb992ffb1570c898fb93049264fb9c8 100644 (file)
@@ -2,7 +2,7 @@
 
      Licensed under GNU General Public License v2
       * (c) 2014,      projektile
-      * (c) 2013,      Luke Bonham
+      * (c) 2013,      Luca CPZ
       * (c) 2010-2012, Peter Hofmann
 
 --]]
index aff27710dc8d31a208fad53200499de762431f9e..cb8370933b660ae496cf562780f7c477f871f4f4 100644 (file)
@@ -4,30 +4,28 @@
       * (c) 2016,      Henrik Antonsson
       * (c) 2015,      Joerg Jaspert
       * (c) 2014,      projektile
-      * (c) 2013,      Luke Bonham
+      * (c) 2013,      Luca CPZ
       * (c) 2010-2012, Peter Hofmann
 
 --]]
 
-local floor  = math.floor
-local screen = screen
+local floor, max, screen = math.floor, math.max, screen
 
 local centerwork = {
-    name         = "centerwork",
-    horizontal   = { name = "centerworkh" }
+    name       = "centerwork",
+    horizontal = { name = "centerworkh" }
 }
 
-local function do_centerwork(p, orientation)
-    local t = p.tag or screen[p.screen].selected_tag
-    local wa = p.workarea
+local function arrange(p, layout)
+    local t   = p.tag or screen[p.screen].selected_tag
+    local wa  = p.workarea
     local cls = p.clients
 
     if #cls == 0 then return end
 
-    local c = cls[1]
-    local g = {}
+    local c, g = cls[1], {}
 
-    -- Main column, fixed width and height.
+    -- Main column, fixed width and height
     local mwfact          = t.master_width_factor
     local mainhei         = floor(wa.height * mwfact)
     local mainwid         = floor(wa.width * mwfact)
@@ -42,7 +40,7 @@ local function do_centerwork(p, orientation)
 
     local slaveFirstDim, slaveSecondDim = 0, 0
 
-    if orientation == "vertical" then
+    if layout.name == "centerwork" then -- vertical
         if nbrFirstSlaves  > 0 then slaveFirstDim  = floor(wa.height / nbrFirstSlaves) end
         if nbrSecondSlaves > 0 then slaveSecondDim = floor(wa.height / nbrSecondSlaves) end
 
@@ -51,7 +49,7 @@ local function do_centerwork(p, orientation)
 
         g.x = wa.x + slaveLwid
         g.y = wa.y
-    else
+    else -- horizontal
         if nbrFirstSlaves  > 0 then slaveFirstDim  = floor(wa.width / nbrFirstSlaves) end
         if nbrSecondSlaves > 0 then slaveSecondDim = floor(wa.width / nbrSecondSlaves) end
 
@@ -62,92 +60,76 @@ local function do_centerwork(p, orientation)
         g.y = wa.y + slaveThei
     end
 
-    if g.width  < 1 then g.width  = 1 end
-    if g.height < 1 then g.height = 1 end
+    g.width  = max(g.width, 1)
+    g.height = max(g.height, 1)
 
     p.geometries[c] = g
 
-    -- Auxiliary windows.
+    -- Auxiliary clients
     if #cls <= 1 then return end
-    for i = 2,#cls do
-        local c = cls[i]
-        local g = {}
+    for i = 2, #cls do
+        local c, g = cls[i], {}
+        local idxChecker, dimToAssign
 
         local rowIndex = floor(i/2)
 
-        if orientation == "vertical" then
-            if i % 2 == 0 then
-                -- left slave
-                g.x = wa.x
-                g.y = wa.y + (rowIndex-1)*slaveFirstDim
-
+        if layout.name == "centerwork" then
+            if i % 2 == 0 then -- left slave
+                g.x     = wa.x
+                g.y     = wa.y + (rowIndex - 1) * slaveFirstDim
                 g.width = slaveLwid
 
-                -- if last slave in left row use remaining space for that slave
-                if rowIndex == nbrFirstSlaves then
-                    g.height = wa.y + wa.height - g.y
-                else
-                    g.height = slaveFirstDim
-                end
-            else
-                -- right slave
-                g.x = wa.x + slaveLwid + mainwid
-                g.y = wa.y + (rowIndex-1)*slaveSecondDim
-
+                idxChecker, dimToAssign = nbrFirstSlaves, slaveFirstDim
+            else -- right slave
+                g.x     = wa.x + slaveLwid + mainwid
+                g.y     = wa.y + (rowIndex - 1) * slaveSecondDim
                 g.width = slaveRwid
 
-                -- if last slave in right row use remaining space for that slave
-                if rowIndex == nbrSecondSlaves then
-                    g.height = wa.y + wa.height - g.y
-                else
-                    g.height = slaveSecondDim
-                end
+                idxChecker, dimToAssign = nbrSecondSlaves, slaveSecondDim
             end
-        else
-            if i % 2 == 0 then
-                -- top slave
-                g.x = wa.x + (rowIndex-1)*slaveFirstDim
-                g.y = wa.y
 
-                g.height = slaveThei
-
-                -- if last slave in top row use remaining space for that slave
-                if rowIndex == nbrFirstSlaves then
-                    g.width = wa.x + wa.width - g.x
-                else
-                    g.width = slaveFirstDim
-                end
+            -- if last slave in row, use remaining space for it
+            if rowIndex == idxChecker then
+                g.height = wa.y + wa.height - g.y
             else
-                -- bottom slave
-                g.x = wa.x + (rowIndex-1)*slaveSecondDim
-                g.y = wa.y + slaveThei + mainhei
+                g.height = dimToAssign
+            end
+        else
+            if i % 2 == 0 then -- top slave
+                g.x      = wa.x + (rowIndex - 1) * slaveFirstDim
+                g.y      = wa.y
+                g.height = slaveThei
 
+                idxChecker, dimToAssign = nbrFirstSlaves, slaveFirstDim
+            else -- bottom slave
+                g.x      = wa.x + (rowIndex - 1) * slaveSecondDim
+                g.y      = wa.y + slaveThei + mainhei
                 g.height = slaveBhei
 
-                -- if last slave in bottom row use remaining space for that slave
-                if rowIndex == nbrSecondSlaves then
-                    g.width = wa.x + wa.width - g.x
-                else
-                    g.width = slaveSecondDim
-                end
+                idxChecker, dimToAssign = nbrSecondSlaves, slaveSecondDim
+            end
 
+            -- if last slave in row, use remaining space for it
+            if rowIndex == idxChecker then
+                g.width = wa.x + wa.width - g.x
+            else
+                g.width = dimToAssign
             end
         end
 
-        if g.width  < 1 then g.width  = 1 end
-        if g.height < 1 then g.height = 1 end
+        g.width  = max(g.width, 1)
+        g.height = max(g.height, 1)
 
         p.geometries[c] = g
     end
 end
 
-
-function centerwork.horizontal.arrange(p)
-    return do_centerwork(p, "horizontal")
+function centerwork.arrange(p)
+    return arrange(p, centerwork)
 end
 
-function centerwork.arrange(p)
-    return do_centerwork(p, "vertical")
+function centerwork.horizontal.arrange(p)
+    return arrange(p, centerwork.horizontal)
 end
 
 return centerwork
index b311f4525ff09e55ebeb249a033f303be29c90f1..6478b06052460446729a9f950fe12e136706da3c 100644 (file)
@@ -6,7 +6,7 @@
      Layouts section
 
      Licensed under GNU General Public License v2
-      * (c) 2013,      Luke Bonham
+      * (c) 2013,      Luca CPZ
       * (c) 2010-2012, Peter Hofmann
 
 --]]
index 60b3c7df1f8ad56b4871adc93caa9bf63dd1bfe2..f57f7158101af2daa0d37d2f841a5eb246844de0 100644 (file)
@@ -2,7 +2,7 @@
 
      Licensed under GNU General Public License v2
       * (c) 2014,      projektile
-      * (c) 2013,      Luke Bonham
+      * (c) 2013,      Luca CPZ
       * (c) 2010,      Nicolas Estibals
       * (c) 2010-2012, Peter Hofmann
 
diff --git a/scripts/dfs b/scripts/dfs
deleted file mode 100755 (executable)
index 9e02a87..0000000
+++ /dev/null
@@ -1,397 +0,0 @@
-#!/usr/bin/env bash
-#
-#   Adapted from Eridan's "fs" (cleanup, enhancements and switch to bash/Linux)
-#   JM,  10/12/2004
-#
-#   Integrated into Lain in september 2013
-#   https://github.com/lcpz/lain
-
-#   Requires gawk
-
-# -------------------------------------------------------------------------
-#   Decoding options
-# -------------------------------------------------------------------------
-USAGE="Usage: $0 [-h(elp)] | [-n(arrow mode)] | [-w(eb output) | --type=<fstype> | --exclude-type=<fstype>]"
-
-NARROW_MODE=0
-WEB_OUTPUT=0
-DF_OPTIONS=""
-
-while [ $# -gt 0 ]; do
-case "$1" in
-"-h" )
-echo $USAGE
-exit
-;;
-"-d" )
-DEBUG=1
-;;
-"-n" )
-NARROW_MODE=1
-;;
-"-w" )
-WEB_OUTPUT=1
-;;
---type=*)
-DF_OPTIONS+=" $1"
-;;
---exclude-type=*)
-DF_OPTIONS+=" $1"
-;;
-* )
-echo $USAGE
-exit
-;;
-esac
-shift
-done
-
-# -------------------------------------------------------------------------
-#   Preparations
-# -------------------------------------------------------------------------
-SYSTEM=`uname -s`
-PATTERN="/"
-
-case "$SYSTEM" in
-"Linux" )
-DF_COMMAND="/usr/bin/env df -k"
-SORT_COMMAND="/usr/bin/env sort -k6"
-AWK_COMMAND="/usr/bin/env awk"
-;;
-* )
-DF_COMMAND="/bin/df -k"
-SORT_COMMAND="/usr/bin/sort -k6"
-AWK_COMMAND="/usr/bin/env gawk"
-;;
-esac
-
-# Add additional df options
-DF_COMMAND+=$DF_OPTIONS
-
-# -------------------------------------------------------------------------
-#   Grabbing "df" result
-# -------------------------------------------------------------------------
-DF_RESULT=`$DF_COMMAND`
-if [ ! -z $DEBUG ]; then
-echo "--> DF_RESULT:"
-echo "$DF_RESULT"
-echo ""
-fi
-
-# -------------------------------------------------------------------------
-#   Preprocessing "df" result, to join split logical lines
-# -------------------------------------------------------------------------
-PREPROCESSING_RESULT=` \
-                                                                                echo "$DF_RESULT" | $AWK_COMMAND -v PATTERN=$PATTERN \
-                                                                                '
-                                                                                NF == 1 {
-                                                                                        printf ("%s", $0)
-                                                                                }
-
-NF == 5 {
-       printf ("%s\n", $0)
-}
-
-NF > 6  {
-}
-
-NF == 6 {
-       printf ("%s\n", $0)
-}'
-`
-if [ ! -z $DEBUG ]; then
-echo "--> PREPROCESSING_RESULT:"
-echo "$PREPROCESSING_RESULT"
-echo ""
-fi
-
-SORTED_FILE_SYSTEMS_INFO=`echo "$PREPROCESSING_RESULT" | $SORT_COMMAND`
-
-if [ ! -z $DEBUG ]; then
-echo "--> SORTED_FILE_SYSTEMS_INFO:"
-echo "$SORTED_FILE_SYSTEMS_INFO"
-echo ""
-fi
-
-# -------------------------------------------------------------------------
-#   Computing mount point max length
-# -------------------------------------------------------------------------
-MOUNT_POINT_MAX_LENGTH=` \
-                                                                                        echo "$SORTED_FILE_SYSTEMS_INFO" | $AWK_COMMAND -v PATTERN=$PATTERN \
-                                                                                        '
-                                                                                        BEGIN       {
-                                                                                                mount_point_length_max = 15;
-                                                                                        }
-
-END     {
-       printf ("%d", mount_point_length_max);
-}
-
-$0 ~ PATTERN    {
-#       printf ("$6 = %s\n", $6);
-
-       mount_point = $6;
-#       printf ("mount_point = %s\n", mount_point);
-
-       mount_point_length = length (mount_point);
-#       printf ("mount_point_length = %d\n", mount_point_length);
-
-       if (mount_point_length > mount_point_length_max)
-               mount_point_length_max = mount_point_length;
-}'
-`
-if [ ! -z $DEBUG ]; then
-echo "MOUNT_POINT_MAX_LENGTH:      $MOUNT_POINT_MAX_LENGTH"
-fi
-
-# -------------------------------------------------------------------------
-#   Computing mount point data max size
-# -------------------------------------------------------------------------
-MOUNT_POINT_MAX_SIZE=` \
-                                                                                echo "$SORTED_FILE_SYSTEMS_INFO" | $AWK_COMMAND -v PATTERN=$PATTERN \
-                                                                                '
-                                                                                BEGIN       {
-                                                                                        mount_point_size_max = 0;
-                                                                                }
-
-END     {
-       printf ("%d", mount_point_size_max);
-}
-
-$0 ~ PATTERN    {
-#       df -k shows k_bytes!
-#       printf ("$2 = %s\n", $2);
-
-       mount_point_size = $2 * 1024;
-#       printf ("mount_point_size = %d\n", mount_point_size);
-
-       if (mount_point_size > mount_point_size_max)
-               mount_point_size_max = mount_point_size;
-}'
-`
-if [ ! -z $DEBUG ]; then
-echo "MOUNT_POINT_MAX_SIZE:      $MOUNT_POINT_MAX_SIZE"
-fi
-
-# -------------------------------------------------------------------------
-#   Let's go!
-# -------------------------------------------------------------------------
-echo "$SORTED_FILE_SYSTEMS_INFO" | $AWK_COMMAND -v DEBUG=$DEBUG -v PATTERN=$PATTERN -v NARROW_MODE=$NARROW_MODE -v LEFT_COLUMN=$MOUNT_POINT_MAX_LENGTH -v MAX_SIZE=$MOUNT_POINT_MAX_SIZE -v SCALE=$SCALE -v WEB_OUTPUT=$WEB_OUTPUT \
-                        '
-#   {printf ("$0 = %s\n", $0);}
-#   {printf ("$1 = %s\n", $1);}
-#   {printf ("PATTERN = %s\n", PATTERN);}
-#   {printf ("LEFT_COLUMN = %s\n", LEFT_COLUMN);}
-
-                        BEGIN       {
-                                k_bytes = 1024.0;
-                                m_bytes = 1024.0 * k_bytes;
-                                g_bytes = 1024.0 * m_bytes;
-                                t_bytes = 1024.0 * g_bytes;
-
-                                if (WEB_OUTPUT)
-                                {
-                                        all_stars = "**************************************************";
-                                        current_date = strftime ("%d-%m-%Y @ %H:%M:%S", localtime (systime ()));
-                                        free_threshold = 10; # %
-
-                                printf ("<!-- DEBUT CONTENU -->\n");
-
-                                        printf ( \
-                                                        "<A NAME=\"top\"></A>\n" \
-                                                        "<P ALIGN=CENTER><SPAN CLASS=\"titleblue\">%s</SPAN><SPAN CLASS=\"textbold\">  --  STATUS OF <SPAN CLASS=\"titlered\">ALCOR</SPAN> FILE SYSTEMS</SPAN></P><BR>\n",
-                                                        current_date )
-
-                                                printf ("<TABLE WIDTH=\"100%%\" BORDER=1>\n");
-
-                                        printf ( \
-                                                        "<TR>\n" \
-                                                        "<TD ALIGN=LEFT><STRONG>Mount point</STRONG></TD>\n" \
-                                                        "<TD ALIGN=CENTER><STRONG>%% Usato&nbsp;(<SPAN CLASS=\"titleblue\">*</SPAN>)" \
-                                                        "&nbsp;-&nbsp;%% Free&nbsp;(<SPAN CLASS=\"titlegreen\">*</SPAN>)</STRONG></TD>\n" \
-                                                        "<TD ALIGN=CENTER><STRONG>%% Used</STRONG></TD>\n" \
-                                                        "<TD ALIGN=CENTER><STRONG>Free</STRONG></TD>\n" \
-                                                        "<TD ALIGN=CENTER><STRONG>Total</STRONG></TD>\n" \
-                                                        "</TR>\n" );
-                                }
-                                else
-                                {
-                                        narrow_margin = "       ";
-#           printf ("%-*s", LEFT_COLUMN + 2, "Mount point");
-                                                if (NARROW_MODE)
-                                                        printf ("\n%s", narrow_margin);
-                                                else
-                                                        printf ("%-*s", LEFT_COLUMN + 2, "");
-                                        print "                                                    Used     Free       Total ";
-                                        if (! NARROW_MODE)
-                                                print " ";
-                                }
-                        }
-
-END     {
-       if (WEB_OUTPUT)
-       {
-               printf ("</TABLE>\n");
-
-               printf ("<!-- FIN CONTENU -->\n");
-       }
-       else
-       {
-               if (NARROW_MODE)
-                       printf ("%s", narrow_margin);
-               else
-                       printf ("%-*s", LEFT_COLUMN + 2, "");
-               print "|----|----|----|----|----|----|----|----|----|----|"
-                       if (NARROW_MODE)
-                               printf ("\n%s", narrow_margin);
-                       else
-                               printf ("%-*s", LEFT_COLUMN + 2, "");
-               print "0   10   20   30   40   50   60   70   80   90  100";
-               print "";
-       }
-}
-
-$0 ~ PATTERN    {
-
-       if (index ($0, "members") == 0 && index ($0, "Download") == 0 && index ($0, "admin") == 0)
-       {
-#       df -k shows k_bytes!
-
-               total_size = $2 * k_bytes;
-               free_size = $4 * k_bytes;
-               percentage_occupied = substr($5, 0, 3);
-               mount_point = $6;
-
-               percentage_free = int (100 - percentage_occupied);
-
-#       reduction_factor: 2
-               stars_number = int (percentage_occupied / 2);
-
-               if (WEB_OUTPUT)
-               {
-                       posGroup = index (mount_point, "scratch");
-                       if (posGroup == 0)
-                               posGroup = index (mount_point, "u1");
-                       if (posGroup == 0)
-                               posGroup = index (mount_point, "u2");
-                       if (posGroup == 0)
-                               posGroup = index (mount_point, "u4");
-                       if (posGroup == 0)
-                               posGroup = index (mount_point, "u5");
-
-                       printf ("<TR>\n");
-
-                       if (posGroup > 0 || percentage_free < free_threshold)
-                       {
-                               if (percentage_free < free_threshold)
-                               {
-                                       class = "titlered";
-                                       if (posGroup == 0)
-                                               posGroup = 1;   # to display the whole mount_point in this color anyway
-                               }
-                               else if ((index (mount_point, "scratch") != 0) || (index (mount_point, "u1") != 0) || (index (mount_point, "u2") != 0))
-                               {
-                                       class = "titleorange";
-                                       posGroup = 1;   # to display the whole mount_point in this color
-                               }
-                               else if ((index (mount_point, "u4") != 0) || (index (mount_point, "u5") != 0))
-                               {
-                                       class = "titlebrown";
-                                       posGroup = 1;   # to display the whole mount_point in this color
-                               }
-
-                               printf ( \
-                                               "<TD ALIGN=LEFT>%s<SPAN CLASS=\"%s\">%s</SPAN></TD>\n",
-                                               substr (mount_point, 1, posGroup - 1),
-                                               class,
-                                               substr (mount_point, posGroup) );
-                       }
-                       else
-                       {
-                               printf ("<TD ALIGN=LEFT>%s</TD>\n", mount_point);
-                       }
-
-                       printf ( \
-                                       "<TD ALIGN=CENTER><SPAN CLASS=\"titleblue\">%s</SPAN><SPAN CLASS=\"titlegreen\">%s</SPAN></TD>\n",
-                                       substr (all_stars, 1, stars_number), substr (all_stars, stars_number + 1, 49) );
-
-                       if (percentage_free < free_threshold)
-                       {
-                               color_beginning = "<SPAN CLASS=\"titlered\">";
-                               color_end = "</SPAN>"
-                       }
-                       else
-                       {
-                               color_beginning = "";
-                               color_end = ""
-                       }
-
-                       if (total_size > 1 * t_bytes)
-                               printf ( \
-                                               "<TD ALIGN=RIGHT>%s%3d%%%s</TD><TD ALIGN=RIGHT>%5.1f Tb</TD><TD ALIGN=RIGHT>%5.1f Tb</TD>\n", \
-                                               color_beginning, percentage_occupied, color_end, free_size / t_bytes, total_size / t_bytes \
-                                               );
-                       else if (total_size > 1 * g_bytes)
-                               printf ( \
-                                               "<TD ALIGN=RIGHT>%s%3d%%%s</TD><TD ALIGN=RIGHT>%5.1f Gb</TD><TD ALIGN=RIGHT>%5.1f Gb</TD>\n", \
-                                               color_beginning, percentage_occupied, color_end, free_size / g_bytes, total_size / g_bytes \
-                                               );
-                       else if (total_size > 1 * m_byptes)
-                               printf ( \
-                                               "<TD ALIGN=RIGHT>%s%3d%%%s</TD><TD ALIGN=RIGHT>%5.1f Mb</TD><TD ALIGN=RIGHT>%5.1f Mb</TD>\n", \
-                                               color_beginning, percentage_occupied, color_end, free_size / m_bytes, total_size / m_bytes \
-                                               );
-                       else
-                               printf ( \
-                                               "<TD ALIGN=RIGHT>%s%3d%%%s</TD><TD ALIGN=RIGHT>%5.1f Kb</TD><TD ALIGN=RIGHT>%5.1f Kb</TD>\n", \
-                                               color_beginning, percentage_occupied, color_end, free_size / k_bytes, total_size / k_bytes \
-                                               );
-
-                       printf ("</TR>\n");
-               }
-
-               else
-               {
-#           printf ("percentage_occupied = %d\n", percentage_occupied);
-#           printf ("percentage_free = %d\n", percentage_free);
-
-                       printf ("%-*s", LEFT_COLUMN + 2, mount_point);
-                       if (NARROW_MODE)
-                               printf ("\n%s", narrow_margin);
-
-#           printf ("stars_number = %d\n", stars_number);
-
-                       printf ("|");
-                       for (i = 1; i <= stars_number && i <= 49; i++)
-                       {
-                               printf ("%s", "*");
-                       }
-                       for (i = stars_number + 1; i <= 49; i++)
-                       {
-                               printf ("%s", "-");
-                       }
-
-
-                       if (total_size > 1 * t_bytes)
-                               printf ( \
-                                               "| %3d%%   %6.1f   %6.1f Tb\n", \
-                                               percentage_occupied, free_size / t_bytes, total_size / t_bytes \
-                                               );
-                       else if (total_size > 1 * g_bytes)
-                               printf ( \
-                                               "| %3d%%   %6.1f   %6.1f Gb\n", \
-                                               percentage_occupied, free_size / g_bytes, total_size / g_bytes \
-                                               );
-                       else if (total_size > 1 * m_byptes)
-                               printf ( \
-                                               "| %3d%%   %6.1f   %6.1f Mb\n", \
-                                               percentage_occupied, free_size / m_bytes, total_size / m_bytes \
-                                               );
-                       else
-                               printf ( \
-                                               "| %3d%%   %6.1f   %6.1f Kb\n", \
-                                               percentage_occupied, free_size / k_bytes, total_size / k_bytes \
-                                               );
-               }
-       }   # if
-}'
index 8e7b8ef12cc3127da8224051f13d53d29941c61c..8b8e719b3b7af6d835129185ae034cfe6ece0358 100644 (file)
@@ -6,7 +6,7 @@
      Utilities section
 
      Licensed under GNU General Public License v2
-      * (c) 2013,      Luke Bonham
+      * (c) 2013,      Luca CPZ
       * (c) 2010-2012, Peter Hofmann
 
 --]]
index 0eb9bfa4f84233fcaca41c94127f5237527d5595..98013318d6f87284a4bcb1444b40696a5ed7c83e 100644 (file)
@@ -1,7 +1,7 @@
 --[[
 
      Licensed under MIT License
-      * (c) 2013, Luke Bonham
+      * (c) 2013, Luca CPZ
       * (c) 2009, Uli Schlachter
       * (c) 2009, Majic
 
index 38b99179b78d44f6baa8fb689147e6efb4bc475a..6271fcd7d947a44779f8faa9b955e4de7f87fe9f 100644 (file)
@@ -1,7 +1,7 @@
 --[[
 
      Licensed under GNU General Public License v2
-      * (c) 2016, Luke Bonham
+      * (c) 2016, Luca CPZ
       * (c) 2015, unknown
 
 --]]
index c86af9293f373a22faceb4d89f9cdceaffaa72b7..29d3005fa46f6feb2fb0ee2a2f58c8f916533e9b 100644 (file)
@@ -1,7 +1,7 @@
 --[[
 
      Licensed under GNU General Public License v2
-      * (c) 2015, Luke Bonham
+      * (c) 2015, Luca CPZ
       * (c) 2015, plotnikovanton
 
 --]]
index 29e3a052b89dee3a82d8dee5b11423123907bd91..2d4891d29abb990aa12adea61d055d39c8f08efd 100644 (file)
@@ -1,7 +1,7 @@
 --[[
 
      Licensed under GNU General Public License v2
-      * (c) 2013, Luke Bonham
+      * (c) 2013, Luca CPZ
       * (c) 2010, Adrian C. <anrxc@sysphere.org>
 
 --]]
index 750933a1eeed49e4c490b049eb67c4fbce940782..b253d4b3ed8d6754e8ce9e46350352acd09d9d58 100644 (file)
@@ -1,7 +1,7 @@
 --[[
 
      Licensed under GNU General Public License v2
-      * (c) 2013, Luke Bonham
+      * (c) 2013, Luca CPZ
       * (c) 2013, Rman
 
 --]]
@@ -113,9 +113,16 @@ local function factory(args)
                 preset.title = preset.title .. " Muted"
             end
 
-            int = math.modf((alsabar._current_level / 100) * awful.screen.focused().mywibox.height)
+            local wib = awful.screen.focused().mywibox
+
+            local tot = wib.height
+            if wib.position == "left" or wib.position == "right" then
+                tot = wib.width
+            end
+
+            int = math.modf((alsabar._current_level / 100) * tot)
             preset.text = string.format("[%s%s]", string.rep("|", int),
-                          string.rep(" ", awful.screen.focused().mywibox.height - int))
+                          string.rep(" ", tot - int))
 
             if alsabar.followtag then preset.screen = awful.screen.focused() end
 
index 8e04569128b6b6131de342f1f805fa14f4ae7fb6..34d63e5495572749b1c6014aa6f8f74beb19de39 100644 (file)
@@ -1,7 +1,7 @@
 --[[
 
         Licensed under GNU General Public License v2
-         * (c) 2013,      Luke Bonham
+         * (c) 2013,      Luca CPZ
          * (c) 2010-2012, Peter Hofmann
 
 --]]
@@ -47,6 +47,14 @@ local function factory(args)
         bg      = "#CDCDCD"
     }
 
+    bat_notification_charged_preset = {
+        title   = "Battery full",
+        text    = "You can unplug the cable",
+        timeout = 15,
+        fg      = "#202020",
+        bg      = "#CDCDCD"
+    }
+
     bat_now = {
         status    = "N/A",
         ac_status = "N/A",
@@ -62,6 +70,9 @@ local function factory(args)
         bat_now.n_perc[i] = 0
     end
 
+    -- used to notify full charge only once before discharging
+    local fullnotification = false
+
     function bat.update()
         local sum_rate_current = 0
         local sum_rate_voltage = 0
@@ -156,18 +167,27 @@ local function factory(args)
         widget = bat.widget
         settings()
 
-        -- notifications for critical and low levels
-        if notify == "on" and bat_now.status == "Discharging" then
-            if tonumber(bat_now.perc) <= n_perc[1] then
-                bat.id = naughty.notify({
-                    preset = bat_notification_critical_preset,
-                    replaces_id = bat.id
-                }).id
-            elseif tonumber(bat_now.perc) <= n_perc[2] then
+        -- notifications for critical, low, and full levels
+        if notify == "on" then
+            if bat_now.status == "Discharging" then
+                if tonumber(bat_now.perc) <= n_perc[1] then
+                    bat.id = naughty.notify({
+                        preset = bat_notification_critical_preset,
+                        replaces_id = bat.id
+                    }).id
+                elseif tonumber(bat_now.perc) <= n_perc[2] then
+                    bat.id = naughty.notify({
+                        preset = bat_notification_low_preset,
+                        replaces_id = bat.id
+                    }).id
+                end
+                fullnotification = false
+            elseif bat_now.status == "Full" and not fullnotification then
                 bat.id = naughty.notify({
-                    preset = bat_notification_low_preset,
+                    preset = bat_notification_charged_preset,
                     replaces_id = bat.id
                 }).id
+                fullnotification = true
             end
         end
     end
index 4f927b38b81bc7265b1f0425320bc002b1ed156e..84b025d5d9b5f707fecf4c0a4b551fc4bc566e20 100644 (file)
@@ -1,7 +1,7 @@
 --[[
 
      Licensed under GNU General Public License v2
-      * (c) 2013, Luke Bonham
+      * (c) 2013, Luca CPZ
 
 --]]
 
index ccc1046b0ef39121aee949c4683923d33c4f1865..9e863a528473cbb2e406d2bbf8ceaa19f209799e 100644 (file)
@@ -6,7 +6,7 @@
      Users contributed widgets section
 
      Licensed under GNU General Public License v2
-      * (c) 2013, Luke Bonham
+      * (c) 2013, Luca CPZ
 
 --]]
 
index d926e8e4b1e76981b3f1fd1f789ceb3f7ed5a6bb..e9675ef42d530b236f23148884b54bc75ac18bb4 100644 (file)
@@ -8,7 +8,7 @@
 
      Licensed under GNU General Public License v2
       * (c) 2013,      Conor Heine
-      * (c) 2013,      Luke Bonham
+      * (c) 2013,      Luca CPZ
       * (c) 2010-2012, Peter Hofmann
 
 --]]
index b6ecb9c1f4fd80cf5811eb102655beb524bb909e..6c6e77a9cde04826c9fb5bb76f3b3a3f85253c01 100644 (file)
@@ -1,7 +1,7 @@
 --[[
 
      Licensed under GNU General Public License v2
-      * (c) 2013,      Luke Bonham
+      * (c) 2013,      Luca CPZ
       * (c) 2010-2012, Peter Hofmann
 
 --]]
index 09e2ef5c95ddf54df10fdeca090b2f2cc6b40ef8..5e18491390b49bfc300ff13661dd465f54a16060 100644 (file)
@@ -1,23 +1,38 @@
 --[[
 
      Licensed under GNU General Public License v2
-      * (c) 2013, Luke Bonham
+      * (c) 2018, Uli Schlacter
+      * (c) 2018, Otto Modinos
+      * (c) 2013, Luca CPZ
 
 --]]
 
-local helpers  = require("lain.helpers")
-local shell    = require("awful.util").shell
-local focused  = require("awful.screen").focused
-local wibox    = require("wibox")
-local naughty  = require("naughty")
-local string   = string
-local tonumber = tonumber
-
--- File system disk space usage
+local helpers    = require("lain.helpers")
+local Gio        = require("lgi").Gio
+local focused    = require("awful.screen").focused
+local wibox      = require("wibox")
+local naughty    = require("naughty")
+local math       = math
+local sformat    = string.format
+local tconcat    = table.concat
+local tonumber   = tonumber
+local query_size = Gio.FILE_ATTRIBUTE_FILESYSTEM_SIZE
+local query_free = Gio.FILE_ATTRIBUTE_FILESYSTEM_FREE
+local query_used = Gio.FILE_ATTRIBUTE_FILESYSTEM_USED
+local query      = query_size .. "," .. query_free .. "," .. query_used
+
+-- File systems info
 -- lain.widget.fs
 
 local function factory(args)
-    local fs = { unit  = { ["mb"] = 1024, ["gb"] = 1024^2 }, widget = wibox.widget.textbox() }
+    local fs = {
+        widget = wibox.widget.textbox(),
+        units = {
+            [1] = "Kb", [2] = "Mb", [3] = "Gb",
+            [4] = "Tb", [5] = "Pb", [6] = "Eb",
+            [7] = "Zb", [8] = "Yb"
+        }
+    }
 
     function fs.hide()
         if not fs.notification then return end
@@ -26,29 +41,20 @@ local function factory(args)
     end
 
     function fs.show(seconds, scr)
-        fs.update()
-        fs.hide()
-
-        if fs.followtag then
-            fs.notification_preset.screen = focused()
-        else
-            fs.notification_preset.screen = scr or 1
-        end
-
-        fs.notification = naughty.notify({
+        fs.hide(); fs.update()
+        fs.notification_preset.screen = fs.followtag and focused() or scr or 1
+        fs.notification = naughty.notify {
             preset  = fs.notification_preset,
             timeout = seconds or 5
-        })
+        }
     end
 
-    local args             = args or {}
-    local timeout          = args.timeout or 600
-    local partition        = args.partition or "/"
-    local showpopup        = args.showpopup or "on"
-    local notify           = args.notify or "on"
-    local settings         = args.settings or function() end
+    local args      = args or {}
+    local timeout   = args.timeout or 600
+    local partition = args.partition
+    local showpopup = args.showpopup or "on"
+    local settings  = args.settings or function() end
 
-    fs.options             = args.options
     fs.followtag           = args.followtag or false
     fs.notification_preset = args.notification_preset
 
@@ -60,54 +66,55 @@ local function factory(args)
         }
     end
 
-    helpers.set_map(partition, false)
-
     function fs.update()
-        fs_info, fs_now  = {}, {}
-        helpers.async({ shell, "-c", "/usr/bin/env LC_ALL=C df -k --output=target,size,used,avail,pcent" }, function(f)
-            for line in string.gmatch(f, "\n[^\n]+") do
-                local m,s,u,a,p = string.match(line, "(/.-%s).-(%d+).-(%d+).-(%d+).-([%d]+)%%")
-                m = m:gsub(" ", "") -- clean target from any whitespace
-
-                fs_info[m .. " size_mb"]  = string.format("%.1f", tonumber(s) / fs.unit["mb"])
-                fs_info[m .. " size_gb"]  = string.format("%.1f", tonumber(s) / fs.unit["gb"])
-                fs_info[m .. " used_mb"]  = string.format("%.1f", tonumber(u) / fs.unit["mb"])
-                fs_info[m .. " used_gb"]  = string.format("%.1f", tonumber(u) / fs.unit["gb"])
-                fs_info[m .. " used_p"]   = p
-                fs_info[m .. " avail_mb"] = string.format("%.1f", tonumber(a) / fs.unit["mb"])
-                fs_info[m .. " avail_gb"] = string.format("%.1f", tonumber(a) / fs.unit["gb"])
-                fs_info[m .. " avail_p"]  = string.format("%d", 100 - tonumber(p))
+        local notifytable = { [1] = sformat("%-10s %-5s %s\t%s\t\n", "fs", "used", "free", "size") }
+        fs_now = {}
+
+        for _, mount in ipairs(Gio.unix_mounts_get()) do
+            local path = Gio.unix_mount_get_mount_path(mount)
+            local root = Gio.File.new_for_path(path)
+            local info = root:query_filesystem_info(query)
+            local size = info:get_attribute_uint64(query_size)
+            local used = info:get_attribute_uint64(query_used)
+            local free = info:get_attribute_uint64(query_free)
+
+            if size > 0 then
+                local units = math.floor(math.log(size)/math.log(1024))
+
+                fs_now[path] = {
+                    units      = fs.units[units],
+                    percentage = math.floor(100 * used / size), -- used percentage
+                    size       = size / math.pow(1024, math.floor(units)),
+                    used       = used / math.pow(1024, math.floor(units)),
+                    free       = free / math.pow(1024, math.floor(units))
+                }
+
+                -- don't notify unused file systems
+                if fs_now[path].percentage > 0 then
+                    notifytable[#notifytable+1] = sformat("\n%-10s %-5s %3.2f\t%3.2f\t%s", path,
+                    fs_now[path].percentage .. "%", fs_now[path].free, fs_now[path].size,
+                    fs_now[path].units)
+                end
             end
+        end
 
-            fs_now.size_mb      = fs_info[partition .. " size_mb"]  or "N/A"
-            fs_now.size_gb      = fs_info[partition .. " size_gb"]  or "N/A"
-            fs_now.used         = fs_info[partition .. " used_p"]   or "N/A"
-            fs_now.used_mb      = fs_info[partition .. " used_mb"]  or "N/A"
-            fs_now.used_gb      = fs_info[partition .. " used_gb"]  or "N/A"
-            fs_now.available    = fs_info[partition .. " avail_p"]  or "N/A"
-            fs_now.available_mb = fs_info[partition .. " avail_mb"] or "N/A"
-            fs_now.available_gb = fs_info[partition .. " avail_gb"] or "N/A"
-
-            notification_preset = fs.notification_preset
-            widget = fs.widget
-            settings()
-
-            if notify == "on" and tonumber(fs_now.used) and tonumber(fs_now.used) >= 99 and not helpers.get_map(partition) then
-                naughty.notify({
+        widget = fs.widget
+        settings()
+
+        if partition and fs_now[partition] and fs_now[partition].used >= 99 then
+            if not helpers.get_map(partition) then
+                naughty.notify {
                     preset = naughty.config.presets.critical,
                     title  = "Warning",
                     text   = partition .. " is full",
-                })
+                }
                 helpers.set_map(partition, true)
             else
                 helpers.set_map(partition, false)
             end
-        end)
+        end
 
-        local notifycmd = (fs.options and string.format("dfs %s", fs.options)) or "dfs"
-        helpers.async(helpers.scripts_dir .. notifycmd, function(ws)
-            fs.notification_preset.text = ws:gsub("\n*$", "")
-        end)
+        fs.notification_preset.text = tconcat(notifytable)
     end
 
     if showpopup == "on" then
@@ -115,7 +122,7 @@ local function factory(args)
        fs.widget:connect_signal('mouse::leave', function () fs.hide() end)
     end
 
-    helpers.newtimer(partition, timeout, fs.update)
+    helpers.newtimer(partition or "fs", timeout, fs.update)
 
     return fs
 end
index 17f37cfefa036348120c7c2ad1355146da59a77d..7c13223e9ed5eb54dbd3eb174458abbcd191ad96 100644 (file)
@@ -1,7 +1,7 @@
 --[[
 
      Licensed under GNU General Public License v2
-      * (c) 2013, Luke Bonham
+      * (c) 2013, Luca CPZ
 
 --]]
 
index e3315d4b54571e5db6dc6bdf1cdce11dda0b99fd..57b86bb986b3c905e70a005bdb1dc30e82195765 100644 (file)
@@ -6,7 +6,7 @@
      Widgets section
 
      Licensed under GNU General Public License v2
-      * (c) 2013,      Luke Bonham
+      * (c) 2013,      Luca CPZ
       * (c) 2010-2012, Peter Hofmann
 
 --]]
index fa2c3649bcde6845614d9978fc926e6eccc0551e..3dcae2b7d9366dddfabf8da718ffe76eff85e79d 100644 (file)
@@ -1,7 +1,7 @@
 --[[
 
      Licensed under GNU General Public License v2
-      * (c) 2013,      Luke Bonham
+      * (c) 2013,      Luca CPZ
       * (c) 2010-2012, Peter Hofmann
 
 --]]
index 38c49dde8d684cf5c3ed39e9c9f1c2758357d6b9..ff451797e96924ddac126c435db7311ebdf1ef99 100644 (file)
@@ -1,7 +1,7 @@
 --[[
 
      Licensed under GNU General Public License v2
-      * (c) 2013, Luke Bonham
+      * (c) 2013, Luca CPZ
       * (c) 2010, Adrian C. <anrxc@sysphere.org>
 
 --]]
index a72fc3de4addfd85d246c77e1df5057f31c87aae..987f047ec3137da0dd15164c5ceff1dd6638ed86 100644 (file)
@@ -1,7 +1,7 @@
 --[[
 
      Licensed under GNU General Public License v2
-      * (c) 2013,      Luke Bonham
+      * (c) 2013,      Luca CPZ
       * (c) 2010-2012, Peter Hofmann
 
 --]]
@@ -15,22 +15,23 @@ local string  = { format = string.format, match = string.match }
 -- lain.widget.net
 
 local function factory(args)
-    local net      = { widget = wibox.widget.textbox(), devices = {} }
-    local args     = args or {}
-    local timeout  = args.timeout or 2
-    local units    = args.units or 1024 -- KB
-    local notify   = args.notify or "on"
-    local screen   = args.screen or 1
-    local settings = args.settings or function() end
+    local net        = { widget = wibox.widget.textbox(), devices = {} }
+    local args       = args or {}
+    local timeout    = args.timeout or 2
+    local units      = args.units or 1024 -- KB
+    local notify     = args.notify or "on"
+    local wifi_state = args.wifi_state or "off"
+    local eth_state  = args.eth_state or "off"
+    local screen     = args.screen or 1
+    local settings   = args.settings or function() end
 
     -- Compatibility with old API where iface was a string corresponding to 1 interface
     net.iface = (args.iface and (type(args.iface) == "string" and {args.iface}) or
                 (type(args.iface) == "table" and args.iface)) or {}
 
     function net.get_device()
-        helpers.async(string.format("ip link show", device_cmd), function(ws)
-            ws = ws:match("(%w+): <BROADCAST,MULTICAST,.-UP,LOWER_UP>")
-            net.iface = ws and { ws } or {}
+        helpers.line_callback("ip link", function(line)
+            net.iface[#net.iface + 1] = not string.match(line, "LOOPBACK") and string.match(line, "(%w+): <") or nil
         end)
     end
 
@@ -45,7 +46,7 @@ local function factory(args)
             received = 0
         }
 
-        for i, dev in ipairs(net.iface) do
+        for _, dev in ipairs(net.iface) do
             local dev_now    = {}
             local dev_before = net.devices[dev] or { last_t = 0, last_r = 0 }
             local now_t      = tonumber(helpers.first_line(string.format("/sys/class/net/%s/statistics/tx_bytes", dev)) or 0)
@@ -66,9 +67,18 @@ local function factory(args)
             dev_now.last_t   = now_t
             dev_now.last_r   = now_r
 
+            if wifi_state == "on" and helpers.first_line(string.format("/sys/class/net/%s/uevent", dev)) == "DEVTYPE=wlan" and string.match(dev_now.carrier, "1") then
+                dev_now.wifi   = true
+                dev_now.signal = tonumber(string.match(helpers.lines_from("/proc/net/wireless")[3], "(%-%d+%.)")) or nil
+            end
+
+            if eth_state == "on" and helpers.first_line(string.format("/sys/class/net/%s/uevent", dev)) ~= "DEVTYPE=wlan" and string.match(dev_now.carrier, "1") then
+                dev_now.ethernet = true
+            end
+
             net.devices[dev] = dev_now
 
-            -- Notify only once when connection is loss
+            -- Notify only once when connection is lost
             if string.match(dev_now.carrier, "0") and notify == "on" and helpers.get_map(dev) then
                 naughty.notify {
                     title    = dev,
@@ -84,7 +94,7 @@ local function factory(args)
             net_now.carrier = dev_now.carrier
             net_now.state = dev_now.state
             net_now.devices[dev] = dev_now
-            -- new_now.sent and net_now.received will be
+            -- net_now.sent and net_now.received will be
             -- the totals across all specified devices
         end
 
index aa9d58e1bd098682d8b72493b4037b0610aa2a28..d37e83aca12e0ab0d2e537118481ae6d85183412 100644 (file)
@@ -1,7 +1,7 @@
 --[[
 
      Licensed under GNU General Public License v2
-      * (c) 2016, Luke Bonham
+      * (c) 2016, Luca CPZ
 
 --]]
 
index 7a0a3d4d9de5b0ce4288871bd3f39a1b1b790a62..30fbb40c4557ee547e189c31268528bd6069be9b 100644 (file)
@@ -1,7 +1,7 @@
 --[[
 
      Licensed under GNU General Public License v2
-      * (c) 2013, Luke Bonham
+      * (c) 2013, Luca CPZ
       * (c) 2013, Rman
 
 --]]
@@ -123,9 +123,16 @@ local function factory(args)
                 preset.title = preset.title .. " muted"
             end
 
-            int = math.modf((pulsebar._current_level / 100) * awful.screen.focused().mywibox.height)
+            local wib = awful.screen.focused().mywibox
+
+            local tot = wib.height
+            if wib.position == "left" or wib.position == "right" then
+                tot = wib.width
+            end
+
+            int = math.modf((pulsebar._current_level / 100) * tot)
             preset.text = string.format("[%s%s]", string.rep("|", int),
-                          string.rep(" ", awful.screen.focused().mywibox.height - int))
+                          string.rep(" ", tot - int))
 
             if pulsebar.followtag then preset.screen = awful.screen.focused() end
 
index 98c0ff791e3b630eadcca90a95ad6e80d742b36d..adf3e035ba4cf5930021e561939fa3cc42761c38 100644 (file)
@@ -1,7 +1,7 @@
 --[[
 
      Licensed under GNU General Public License v2
-      * (c) 2013,      Luke Bonham
+      * (c) 2013,      Luca CPZ
       * (c) 2010-2012, Peter Hofmann
 
 --]]
index cc9f0566c279729c43cfd49e0e820b1e222919f8..3c93252b113fc9bb3463342ab44e0c3205566210 100644 (file)
@@ -1,7 +1,7 @@
 --[[
 
      Licensed under GNU General Public License v2
-      * (c) 2013, Luke Bonham
+      * (c) 2013, Luca CPZ
 
 --]]
 
index b75afc8560936fc3936559fba113ff239bb1f81f..a9b886a12f9ea3df7774595e8b96c18f00bcb45f 100644 (file)
@@ -1,7 +1,7 @@
 --[[
 
      Licensed under GNU General Public License v2
-      * (c) 2015, Luke Bonham
+      * (c) 2015, Luca CPZ
 
 --]]
 
@@ -20,7 +20,7 @@ local math, os, string, tonumber = math, os, string, tonumber
 local function factory(args)
     local weather               = { widget = wibox.widget.textbox() }
     local args                  = args or {}
-    local APPID                 = args.APPID or "3e321f9414eaedbfab34983bda77a66e" -- lain default
+    local APPID                 = args.APPID or "3e321f9414eaedbfab34983bda77a66e" -- lain's default
     local timeout               = args.timeout or 60 * 15 -- 15 min
     local timeout_forecast      = args.timeout or 60 * 60 * 24 -- 24 hrs
     local current_call          = args.current_call  or "curl -s 'http://api.openweathermap.org/data/2.5/weather?id=%s&units=%s&lang=%s&APPID=%s'"
@@ -114,22 +114,18 @@ local function factory(args)
                 local sunrise = tonumber(weather_now["sys"]["sunrise"])
                 local sunset  = tonumber(weather_now["sys"]["sunset"])
                 local icon    = weather_now["weather"][1]["icon"]
-                local loc_now = os.time()
-                local loc_m   = os.time { year = os.date("%Y"), month = os.date("%m"), day = os.date("%d"), hour = 0 }
-                local loc_t   = os.difftime(loc_now, loc_m)
-                local loc_d   = os.date("*t",  loc_now)
-                local utc_d   = os.date("!*t", loc_now)
-                local utc_now = os.time(utc_d)
-                local offdt   = (loc_d.isdst and 1 or 0) * 3600 + 100 * (loc_d.min  - utc_d.min) / 60
-                local offset  = os.difftime(loc_now, utc_now) + offdt
-                local offday  = (offset < 0 and -86400) or 86400
-
-                if math.abs(loc_now - utc_now - offdt + loc_t) >= 86400 then
-                    utc_now = utc_now + offday
-                end
-
-                if offday * (loc_now - utc_now - offdt) > 0 then
-                    sunrise = sunrise + offday
+                local loc_now = os.time() -- local time
+                local loc_m   = os.time { year = os.date("%Y"), month = os.date("%m"), day = os.date("%d"), hour = 0 } -- local time from midnight
+                local loc_d   = os.date("*t",  loc_now) -- table YMDHMS for current local time (for TZ calculation)
+                local utc_d   = os.date("!*t", loc_now) -- table YMDHMS for current UTC time
+                local utc_now = os.time(utc_d) -- UTC time now
+                local offdt   = (loc_d.isdst and 1 or 0) * 3600 + 100 * (loc_d.min  - utc_d.min) / 60 -- DST offset
+                local offset  = os.difftime(loc_now, utc_now) + (loc_d.isdst and 1 or 0) * 3600 + 100 * (loc_d.min  - utc_d.min) / 60 -- TZ offset (including DST)
+                local offday  = (offset < 0 and -86400) or 86400 -- 24 hour correction value (+86400 or -86400)
+
+                -- if current UTC time is earlier then local midnight -> positive offset (negative otherwise)
+                if offset * (loc_m - utc_now + offdt) > 0 then
+                    sunrise = sunrise + offday -- Shift sunset and sunrise times by 24 hours
                     sunset  = sunset  + offday
                 end
 
diff --git a/wiki b/wiki
index f395683e491fabd539fa0b5d596dbb5cc451e68e..e8860c7593f86584b45ada7d5232f32915ba20a6 160000 (submodule)
--- a/wiki
+++ b/wiki
@@ -1 +1 @@
-Subproject commit f395683e491fabd539fa0b5d596dbb5cc451e68e
+Subproject commit e8860c7593f86584b45ada7d5232f32915ba20a6