Check mail in separate process to prevent freezing of the interface.

This commit is contained in:
Kolan Sh 2014-08-15 13:43:49 +04:00
parent d54799aece
commit b1746089e1
3 changed files with 26 additions and 24 deletions

View File

@ -8,5 +8,6 @@ os.execute ("pgrep firefox || (firefox || firefox-bin) &")
os.execute ("pgrep geary || geary &") os.execute ("pgrep geary || geary &")
os.execute ("smbnetfs "..os.getenv("HOME").."/smb") os.execute ("smbnetfs "..os.getenv("HOME").."/smb")
os.execute (os.getenv("HOME").."/.config/awesome/set_wall.sh "..os.getenv("HOME").."/.config/awesome/wallpaper.slink") os.execute (os.getenv("HOME").."/.config/awesome/set_wall.sh "..os.getenv("HOME").."/.config/awesome/wallpaper.slink")
os.execute ("pgrep mail_loop.sh || "..os.getenv("HOME").."/.config/awesome/mail_loop.sh &")
os.execute ("pgrep lightsOn.sh || "..os.getenv("HOME").."/.config/awesome/lightsOn.sh &") os.execute ("pgrep lightsOn.sh || "..os.getenv("HOME").."/.config/awesome/lightsOn.sh &")
os.execute ("pgrep nm-applet || nm-applet &") os.execute ("pgrep nm-applet || nm-applet &")

11
mail_loop.sh Executable file
View File

@ -0,0 +1,11 @@
#!/bin/bash
# mymail_gmail_loop.sh
while [ 1 ]; do
val=$(~/.config/awesome/mymail_unread.py)
echo $val > ~/.mymail_count
sleep 30
val=$(~/.config/awesome/gmail_unread.py)
echo $val > ~/.gmail_count
sleep 30
done

38
rc.lua
View File

@ -222,42 +222,32 @@ mytasklist.buttons = awful.util.table.join(
if client.focus then client.focus:raise() end if client.focus then client.focus:raise() end
end)) end))
-- My MyMail updater widget -- My Mail updater widget
function mymail_count() function mail_count(filename)
os.execute("~/.config/awesome/mymail_unread.py > ~/.mymail_count") local f = io.open(filename)
local f = io.open(os.getenv("HOME") .. "/.mymail_count")
local l = nil local l = nil
if f ~= nil then if f ~= nil then
l = f:read() l = f:read()
if l == nil then
l = "?"
end
else else
l = "?" l = "?"
end end
f:close() f:close()
return l return l
end end
mymail_mail = wibox.widget.textbox( mymail_count() ) mymail_mail = wibox.widget.textbox( "?" )
mymail_mail.timer = timer{timeout=60} mymail_mail.timer = timer{timeout=20}
mymail_mail.timer:connect_signal("timeout", function () mymail_mail:set_text ( mymail_count() ) end) mymail_mail.timer:connect_signal("timeout",
function () mymail_mail:set_text ( mail_count(os.getenv("HOME") .. "/.mymail_count") ) end)
mymail_mail.timer:start() mymail_mail.timer:start()
mymailicon = wibox.widget.imagebox() mymailicon = wibox.widget.imagebox()
mymailicon:set_image(beautiful.widget_mymail) mymailicon:set_image(beautiful.widget_mymail)
gmail_mail = wibox.widget.textbox( "?" )
-- My GMail updater widget gmail_mail.timer = timer{timeout=20}
function gmail_count() gmail_mail.timer:connect_signal("timeout",
os.execute("~/.config/awesome/gmail_unread.py > ~/.gmail_count") function () gmail_mail:set_text ( mail_count(os.getenv("HOME") .. "/.gmail_count") ) end)
local f = io.open(os.getenv("HOME") .. "/.gmail_count")
local l = nil
if f ~= nil then
l = f:read()
else
l = "?"
end
f:close()
return l
end
gmail_mail = wibox.widget.textbox( gmail_count() )
gmail_mail.timer = timer{timeout=60}
gmail_mail.timer:connect_signal("timeout", function () gmail_mail:set_text ( gmail_count() ) end)
gmail_mail.timer:start() gmail_mail.timer:start()
mymailicon = wibox.widget.imagebox() mymailicon = wibox.widget.imagebox()
mymailicon:set_image(beautiful.widget_mymail) mymailicon:set_image(beautiful.widget_mymail)