Add timelogger to status bar
This commit is contained in:
parent
1fa4ecee5a
commit
f1c009e59b
@ -6,7 +6,7 @@
|
||||
# ----------------------------------------------------------------------
|
||||
|
||||
auto-reload yes
|
||||
browser lynx
|
||||
browser surf
|
||||
cleanup-on-quit yes
|
||||
# download-path "/home/moparx/downloads/podcasts"
|
||||
feed-sort-order title-dec
|
||||
|
||||
@ -1,12 +0,0 @@
|
||||
-- Create a statusbar
|
||||
-- mod_statusbar.create{
|
||||
-- screen=0,
|
||||
-- pos='bl',
|
||||
-- fullsize=true,
|
||||
-- systray=true,
|
||||
-- template="[ %date || %load || ... ] %systray%filler%systray_stalone",
|
||||
-- }
|
||||
--
|
||||
-- defwinprop{class="stalonetray",instance="stalonetray",statusbar="systray_stalone"}
|
||||
-- defwinprop{instance="stalonetray",statusbar="systray_stalone"}
|
||||
-- defwinprop{class="stalonetray",statusbar="systray_stalone"}
|
||||
@ -1,54 +0,0 @@
|
||||
--
|
||||
-- Notion dock module configuration
|
||||
--
|
||||
|
||||
-- Create a dock.
|
||||
mod_dock.create{
|
||||
-- Dock mode: embedded|floating.
|
||||
mode="floating",
|
||||
|
||||
-- The screen to create the dock on.
|
||||
screen=0,
|
||||
|
||||
-- Corner or side of the screen to place the dock on.
|
||||
-- For embedded dock the valid values are: tl|tr|bl|br.
|
||||
-- For floating dock the following are also valid: tc|bc|ml|mc|mr.
|
||||
pos="bl",
|
||||
|
||||
-- Growth direction: left|right|up|down.
|
||||
grow="right",
|
||||
|
||||
-- Whether new dockapps should be added automatically to this dock.
|
||||
is_auto=true,
|
||||
|
||||
-- Show floating dock initially?
|
||||
floating_hidden=false,
|
||||
|
||||
-- Name of the dock.
|
||||
name="*dock*",
|
||||
}
|
||||
|
||||
-- For floating docks, you may want the following toggle binding.
|
||||
defbindings("WScreen", {
|
||||
bdoc("Toggle floating dock."),
|
||||
kpress(META.."D", "mod_dock.set_floating_shown_on(_, 'toggle')"),
|
||||
})
|
||||
|
||||
-- Dock settings menu. For this to work, mod_menu must have been loaded
|
||||
-- previously.
|
||||
if mod_menu then
|
||||
defmenu("dock-settings", {
|
||||
menuentry("Pos-TL", "_:set{pos='tl'}"),
|
||||
menuentry("Pos-TR", "_:set{pos='tr'}"),
|
||||
menuentry("Pos-BL", "_:set{pos='bl'}"),
|
||||
menuentry("Pos-BR", "_:set{pos='br'}"),
|
||||
menuentry("Grow-L", "_:set{grow='left'}"),
|
||||
menuentry("Grow-R", "_:set{grow='right'}"),
|
||||
menuentry("Grow-U", "_:set{grow='up'}"),
|
||||
menuentry("Grow-D", "_:set{grow='down'}"),
|
||||
})
|
||||
|
||||
defbindings("WDock", {
|
||||
mpress("Button3", "mod_menu.pmenu(_, _sub, 'dock-settings')"),
|
||||
})
|
||||
end
|
||||
@ -143,7 +143,7 @@ defbindings("WMPlex.toplevel", {
|
||||
kpress(META.."T", "WRegion.set_tagged(_sub, 'toggle')", "_sub:non-nil"),
|
||||
|
||||
bdoc("Lock screen"),
|
||||
kpress(META.."L", "notioncore.exec_on(_, notioncore.lookup_script('notion-lock'))"),
|
||||
kpress(META.."L", "notioncore.exec_on(_, 'locker')"),
|
||||
|
||||
--bdoc("Query for manual page to be displayed."),
|
||||
--kpress(META.."F1", "mod_query.query_man(_, ':man')"),
|
||||
@ -363,7 +363,7 @@ defmenu("mainmenu", {
|
||||
menuentry("Run...", "mod_query.query_exec(_)"),
|
||||
menuentry("Terminal", "mod_query.exec_on_merr(_, XTERM or 'urxvt')"),
|
||||
menuentry("Lock screen",
|
||||
"notioncore.exec_on(_, notioncore.lookup_script('notion-lock'))"),
|
||||
"notioncore.exec_on(_, 'locker')"),
|
||||
menuentry("Help", "mod_query.query_man(_)"),
|
||||
menuentry("About Notion", "mod_query.show_about_ion(_)"),
|
||||
submenu("Styles", "stylemenu"),
|
||||
|
||||
@ -37,7 +37,7 @@ mod_statusbar.create{
|
||||
-- right, respectively, and %systray is a placeholder for system tray
|
||||
-- windows and icons.
|
||||
--
|
||||
template=" %battery | %load | %mem_available | %taskwarrior %filler %timelogger | %systray | %date ",
|
||||
template=" %battery %battery_remaining | %load | %mem_available | %cpufreq_M %filler %pomodoro [ %timelogger ] %systray | %date ",
|
||||
--template="[ %date || load:% %>load || mail:% %>mail_new/%>mail_total ] %filler%systray",
|
||||
--template="[ %date || load: %05load_1min || mail: %02mail_new/%02mail_total ] %filler%systray",
|
||||
}
|
||||
@ -50,7 +50,7 @@ mod_statusbar.launch_statusd{
|
||||
-- ISO-8601 date format with additional abbreviated day name.
|
||||
--date_format='%a %Y-%m-%d %H:%M',
|
||||
-- Finnish etc. date format
|
||||
date_format='%A, %d.%m.%Y | %H:%M',
|
||||
date_format='%A, %d.%m.%Y [ %H:%M ]',
|
||||
-- Locale date format (usually shows seconds, which would require
|
||||
-- updating rather often and can be distracting)
|
||||
-- date_format='%c',
|
||||
@ -70,6 +70,11 @@ mod_statusbar.launch_statusd{
|
||||
--critical_threshold=4.0,
|
||||
},
|
||||
|
||||
-- Cpufreq
|
||||
cpufreq={
|
||||
update_interval=5*1000
|
||||
},
|
||||
|
||||
-- Mail meter
|
||||
--
|
||||
-- To monitor more mbox files, add them to the files table. For
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
|
||||
|
||||
local battery_base_settings = {
|
||||
update_interval = 15*1000, -- every 15 sec
|
||||
update_interval = 10*1000, -- every 15 sec
|
||||
important_threshold = 33 , -- 33% cap. remaining
|
||||
critical_threshold = 15, -- 15% capacity remaining
|
||||
}
|
||||
@ -38,15 +38,21 @@ local function read_battery_data ()
|
||||
local f = assert(io.open("/sys/class/power_supply/BAT0/uevent", "r"))
|
||||
local data = f:read("*all")
|
||||
f:close()
|
||||
|
||||
local f = assert(io.popen("acpi -b | awk '{ print $5 }'"))
|
||||
local remaining = f:read("*all")
|
||||
f:close()
|
||||
|
||||
local _, _, capacity = string.find(data, "POWER_SUPPLY_CAPACITY=(%d+)")
|
||||
local _, _, status = string.find(data, "POWER_SUPPLY_STATUS=(%w+)")
|
||||
return status, tonumber(capacity)
|
||||
|
||||
return status, tonumber(capacity), remaining
|
||||
end
|
||||
|
||||
-- Write the current state to the statusbar:
|
||||
local function inform_battery ()
|
||||
|
||||
local status, cap = read_battery_data()
|
||||
local status, cap, remaining = read_battery_data()
|
||||
|
||||
if status == 'Discharging' then
|
||||
-- On battery power, percentage remaining:
|
||||
@ -61,6 +67,8 @@ local function inform_battery ()
|
||||
elseif cap <= battery_settings.important_threshold then
|
||||
statusd.inform("battery_hint", "important")
|
||||
end
|
||||
|
||||
statusd.inform("battery_remaining", remaining)
|
||||
end
|
||||
|
||||
|
||||
|
||||
40
.notion/statusd_cpufreq.lua
Normal file
40
.notion/statusd_cpufreq.lua
Normal file
@ -0,0 +1,40 @@
|
||||
-- Authors: Unknown
|
||||
-- License: Public domain
|
||||
-- Last Changed: Unknown
|
||||
--
|
||||
-- statusd_cpufreq.lua
|
||||
--
|
||||
-- Public domain
|
||||
--
|
||||
-- Use the key "cpufreq_[KMG]" to get the current CPU frequency in
|
||||
-- K/M/GHz, according to /sys/devices/system/cpu/cpuX/cpufreq/. (This
|
||||
-- has the advantage of being a much "rounder" number than the one in
|
||||
-- /proc/cpuinfo, as provided by statusd_cpuspeed.lua.)
|
||||
--
|
||||
-- The "cpu" option to the statusd settings for cpufreq modifies which
|
||||
-- cpu we look at.
|
||||
|
||||
local defaults={ update_interval=2*1000, cpu=0 }
|
||||
local settings=table.join(statusd.get_config("cpufreq"), defaults)
|
||||
|
||||
function get_cpufreq()
|
||||
local f=io.open('/sys/devices/system/cpu/cpu'.. settings.cpu ..'/cpufreq/scaling_cur_freq')
|
||||
local cpufreq_K = f:read('*a')
|
||||
f:close()
|
||||
|
||||
local cpufreq_M = cpufreq_K / 1000
|
||||
local cpufreq_G = cpufreq_M / 1000
|
||||
|
||||
return tostring(cpufreq_K), tostring(cpufreq_M), tostring(cpufreq_G)
|
||||
end
|
||||
|
||||
function update_cpufreq()
|
||||
local cpufreq_K, cpufreq_M, cpufreq_G = get_cpufreq()
|
||||
statusd.inform("cpufreq_K", cpufreq_K)
|
||||
statusd.inform("cpufreq_M", cpufreq_M)
|
||||
statusd.inform("cpufreq_G", cpufreq_G)
|
||||
cpufreq_timer:set(settings.update_interval, update_cpufreq)
|
||||
end
|
||||
|
||||
cpufreq_timer = statusd.create_timer()
|
||||
update_cpufreq()
|
||||
@ -1,100 +0,0 @@
|
||||
-- A battery statusbar meter for the ion3 window manager for Apple Powerbooks
|
||||
-- running Linux. These machines do not use APM or ACPI but have a PMU, Power
|
||||
-- Management Unit.
|
||||
--
|
||||
-- Install the meter in ~/.ion3/statusd_pmu.lua
|
||||
--
|
||||
-- Edit your ~/.ion3/cfg_statusbar.lua to add this meter:
|
||||
-- template="%date - %pmu_battery %filler%systray",
|
||||
--
|
||||
-- When the battery is charged and you're on AC power, you don't see anything.
|
||||
-- When the system is on AC power and charging the battery, you'll see a tilde
|
||||
-- sign, ~, followed by the percentage that the battery is charged. When the
|
||||
-- system is running on battery power, you'll an equal, =, sign, followed by
|
||||
-- the remaining capacity in percentages.
|
||||
--
|
||||
-- See /usr/src/linux/include/pmu.h and
|
||||
-- /usr/src/linux/drivers/macintosh/via-pmu.c for some documentation on the
|
||||
-- exported data.
|
||||
--
|
||||
-- Author: Jeroen Pulles
|
||||
-- Rotterdam, 15 november 2007
|
||||
|
||||
|
||||
local pmu_base_settings = {
|
||||
update_interval = 60*1000, -- every minute
|
||||
--important_threshold = 33 , -- 33% cap. remaining
|
||||
--critical_threshold = 8, -- 8% capacity remaining
|
||||
}
|
||||
|
||||
local pmu_settings = pmu_base_settings
|
||||
|
||||
local pmu_timer
|
||||
|
||||
|
||||
-- Read the pmu battery info
|
||||
local function read_acpi_data ()
|
||||
local cmd = 'acpi -b'
|
||||
local f = assert(io.popen(cmd, 'r'))
|
||||
local bat = assert(f:read('*a'))
|
||||
f:close()
|
||||
return tostring(bat)
|
||||
end
|
||||
|
||||
|
||||
-- Print the battery status to stdout, for debugging purposes:
|
||||
local function print_batt_info ()
|
||||
local battery = read_acpi_data ()
|
||||
print(battery)
|
||||
end
|
||||
|
||||
|
||||
-- Write the current state to the statusbar:
|
||||
local function inform_pmu ()
|
||||
|
||||
local bat = read_acpi_data ()
|
||||
|
||||
--if amp == 0 then
|
||||
---- Do no show anything when on AC power and fully charged:
|
||||
--statusd.inform("pmu_battery", "")
|
||||
--elseif amp > 0 then
|
||||
---- Charging the battery on AC power, percentage charged:
|
||||
--statusd.inform("pmu_battery", string.format("~%d%%", pct))
|
||||
--else
|
||||
---- On battery power, percentage remaining:
|
||||
--statusd.inform("pmu_battery", string.format("=%d%%", pct))
|
||||
--end
|
||||
statusd.inform("pmu_battery", bat)
|
||||
|
||||
-- crit and imp. hints only when on battery:
|
||||
--if amp < 0 and pct <= pmu_settings.critical_threshold then
|
||||
--statusd.inform("pmu_battery_hint", "critical")
|
||||
--elseif amp < 0 and pct <= pmu_settings.important_threshold then
|
||||
--statusd.inform("pmu_battery_hint", "important")
|
||||
--else
|
||||
--statusd.inform("pmu_battery_hint", "normal")
|
||||
--end
|
||||
|
||||
end
|
||||
|
||||
|
||||
-- Statusbar update loop:
|
||||
local function update_pmu ()
|
||||
inform_pmu()
|
||||
pmu_timer:set(pmu_settings.update_interval, update_pmu)
|
||||
end
|
||||
|
||||
|
||||
-- Run the script:
|
||||
if statusd then
|
||||
-- we're a statusbar plugin:
|
||||
pmu_settings = table.join(statusd.get_config("pmu"), pmu_base_settings)
|
||||
pmu_timer = statusd.create_timer()
|
||||
update_pmu()
|
||||
else
|
||||
-- run as standalone:
|
||||
print_batt_info()
|
||||
|
||||
end
|
||||
|
||||
-- vim: set ts=4 sw=4 expandtab
|
||||
41
.notion/statusd_pomodoro.lua
Normal file
41
.notion/statusd_pomodoro.lua
Normal file
@ -0,0 +1,41 @@
|
||||
local pomodoro_base_settings = {
|
||||
update_interval = 5*1000 -- 5 seconds
|
||||
}
|
||||
|
||||
local pomodoro_settings = pomodoro_base_settings
|
||||
|
||||
local pomodoro_timer
|
||||
|
||||
-- Read the active pomodoro
|
||||
local function read_pomodoro_data ()
|
||||
local f = assert(io.popen("pomodoro status"))
|
||||
local data = f:read("*all")
|
||||
f:close()
|
||||
return data
|
||||
end
|
||||
|
||||
-- Write the current state to the statusbar:
|
||||
local function inform_pomodoro ()
|
||||
|
||||
local pomodoro = read_pomodoro_data()
|
||||
|
||||
statusd.inform("pomodoro", pomodoro)
|
||||
end
|
||||
|
||||
|
||||
-- Statusbar update loop:
|
||||
local function update_pomodoro ()
|
||||
inform_pomodoro()
|
||||
pomodoro_timer:set(pomodoro_settings.update_interval, update_pomodoro)
|
||||
end
|
||||
|
||||
|
||||
-- Run the script:
|
||||
if statusd then
|
||||
-- we're a statusbar plugin:
|
||||
pomodoro_settings = table.join(statusd.get_config("pomodoro"), pomodoro_base_settings)
|
||||
pomodoro_timer = statusd.create_timer()
|
||||
update_pomodoro()
|
||||
end
|
||||
|
||||
-- vim: set ts=4 sw=4 expandtab
|
||||
@ -8,19 +8,27 @@ local timelogger_timer
|
||||
|
||||
-- Read the active timelogger
|
||||
local function read_timelogger_data ()
|
||||
local f = assert(io.popen("head -n 1 $HOME/tmp/timelogger.state | awk '{ print $1 }'"))
|
||||
local data = f:read("*all")
|
||||
local f = assert(io.popen("timelogger status"))
|
||||
local current = f:read("*all")
|
||||
f:close()
|
||||
return tonumber(data)
|
||||
local f = assert(io.popen("timelogger today"))
|
||||
local total = f:read("*all")
|
||||
f:close()
|
||||
return tonumber(current), tonumber(total)
|
||||
end
|
||||
|
||||
-- Write the current state to the statusbar:
|
||||
local function inform_timelogger ()
|
||||
|
||||
local timelogger = read_timelogger_data()
|
||||
local tl_current, tl_total = read_timelogger_data()
|
||||
|
||||
statusd.inform("timelogger", tostring(math.floor(timelogger/60).." min"))
|
||||
statusd.inform("timelogger_hint", timelogger >= 25*60 and "critical" or "important")
|
||||
statusd.inform("timelogger", tostring(math.floor(tl_current/60).." min / "..tostring(math.ceil(tl_total/3600).." hr")))
|
||||
|
||||
if tl_current >= 40*60 then
|
||||
statusd.inform("timelogger_hint", "critical")
|
||||
elseif tl_current >= 25*60 then
|
||||
statusd.inform("timelogger_hint", "important")
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user