Remove dependency on delightful's calendar

* new calendar dev is in progress
This commit is contained in:
2013-10-26 01:48:38 +03:00
parent bc54b627f0
commit edad3dec49
4 changed files with 66 additions and 66 deletions

View File

@@ -120,23 +120,23 @@ externals.sounds.pulse = {
--{{{ powers.pm
externals.powers.pm = {
exec = function(command)
awful.util.spawn('sudo ' .. command)
awful.util.spawn('systemctl ' .. command)
end,
reboot = function()
externals.powers.pm.exec('shutdown -r now -t 10')
externals.powers.pm.exec('reboot')
end,
halt = function()
externals.powers.pm.exec('shutdown -h now -t 10')
externals.powers.pm.exec('poweroff')
end,
suspend = function()
externals.powers.pm.exec('pm-suspend')
externals.powers.pm.exec('suspend')
end,
hibernate = function()
externals.powers.pm.exec('pm-hibernate')
externals.powers.pm.exec('hibernate')
end,
switch_profile = function()

View File

@@ -1,44 +1,18 @@
function calendar()
local head = 'Su Mo Tu We Th Fr Sa'
local title = os.date('%B %Y')
while title:len() < head:len() do
title = ' ' .. title .. ' '
function for_month(month, year)
--local month_end = os.time(year = year, month = month + 1)
--local d = os.date("*t", month_end)
--local days, first_day = d.day, (d.wday - d.day) % 7
-- build header
local text = " "
for day_of_week = 1, 7 do
-- Jan 1 2006 is Sunday
text = text .. os.date("%a ", os.time{year = 2006, month = 1, day = day_of_week})
end
local calendar = title .. "\n" .. head .. "\n"
text = text .. "\n" .. month .. "." .. year
local today_w = tonumber(os.date('%u'))
local today_m = tonumber(os.date('%d'))
local day_w = (today_w - today_m + 1) % 7
local daysmap = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }
local year = tonumber(os.date('%Y'))
if year % 4 == 0 and (year % 100 ~= 0 or year % 400 == 0) then
daysmap[2] = 29
end
calendar = calendar .. string.format('%' .. (day_w*3) .. 's', '')
local month = tonumber(os.date('%m'))
for day_m = 1,daysmap[month] do
if day_m > 9 then
day_s = day_m
else
day_s = '0' .. day_m
end
if day_m == today_m then
day_s = '<span color="yellow"><b>' .. day_s .. '</b></span>'
end
calendar = calendar .. day_s .. ' '
day_w = day_w + 1
if day_w > 6 then
day_w = 0
calendar = calendar .. "\n"
end
end
return calendar;
return text
end
return { for_month = for_month }

View File

@@ -13,7 +13,7 @@ local menubar = require("menubar")
-- Delightful Widgets (OMG paths)
--require('widgets.delightful.delightful.widgets.cpu')
require('widgets.delightful.delightful.widgets.datetime')
local widgets_date = require('widgets.date')
--require('widgets.delightful.delightful.widgets.imap')
--require('widgets.delightful.delightful.widgets.memory')
--require('widgets.delightful.delightful.widgets.network')
@@ -296,7 +296,7 @@ for s = 1, screen.count() do
--right_layout:add(awful.widget.textclock())
local delightful_container = { widgets = {}, icons = {} }
local widgets, icons = delightful.widgets.datetime:load()
local widgets, icons = widgets_date:create()
if widgets then
if not icons then
icons = {}

View File

@@ -1,23 +1,49 @@
require("../misc/calendar")
local calendar = require("../misc/calendar")
local awful = require('awful')
local beautiful = require('beautiful')
local wibox = require('wibox')
local vicious = require('vicious')
-- {{{ OK: Date and time
datewidget = {}
datewidget.i = wibox.widget.imagebox()
datewidget.i:set_image(beautiful.widget_date)
datewidget.w = wibox.widget.textbox()
datewidget.format = '%a, %m/%d %R'
datewidget.t = awful.tooltip({
objects = { datewidget.w, datewidget.i },
timer_function = function()
return calendar();
function create(self, format)
local icon = wibox.widget.imagebox()
icon:set_image(beautiful.widget_date)
local widget = wibox.widget.textbox()
local format = format or '%a, %m/%d %R'
local year, month = 0
local tooltip = awful.tooltip({
objects = { widget, icon },
timer_function = function()
widget:set_text(os.date(' ' .. format .. ':%S '))
month, year = os.date('%m'), os.date('%Y')
return calendar.for_month(month, year)
end,
timeout = 60 * 60
})
function adjust_calendar(delta_months)
month = month + delta_months
tooltip:set_text(calendar.for_month(month, year))
end
})
datewidget.b = awful.util.table.join(
awful.button({ }, 1, function ()
datewidget.w:set_text(os.date(datewidget.format .. ':%S'))
end)
)
datewidget.w:buttons(datewidget.b)
datewidget.i:buttons(datewidget.b)
vicious.register(datewidget.w, vicious.widgets.date, datewidget.format, 61)
local button = awful.util.table.join(
awful.button({ }, 1, function()
adjust_calendar(-1)
end),
awful.button({ }, 3, function()
adjust_calendar(1)
end),
awful.button({ 'Shift' }, 1, function()
adjust_calendar(-12)
end),
awful.button({ 'Shift' }, 3, function()
adjust_calendar(12)
end)
)
widget:buttons(button)
icon:buttons(button)
vicious.register(widget, vicious.widgets.date, ' ' .. format .. ' ', 61)
return { widget, icon }
end
return { create = create }
-- }}}