mirror of
https://github.com/kastdeur/dotfiles.git
synced 2025-05-14 20:09:26 +02:00
Updated mainprofile, removed autoindent in vim. Set up awesome.lua with xinitrc. See if it works
This commit is contained in:
parent
3bbb4d6c9a
commit
cc8ca493c8
15 changed files with 600 additions and 507 deletions
113
awesome/widgets/calendar2.lua
Normal file
113
awesome/widgets/calendar2.lua
Normal file
|
@ -0,0 +1,113 @@
|
|||
-- original code made by Bzed and published on http://awesome.naquadah.org/wiki/Calendar_widget
|
||||
-- modified by Marc Dequènes (Duck) <Duck@DuckCorp.org> (2009-12-29), under the same licence,
|
||||
-- and with the following changes:
|
||||
-- + transformed to module
|
||||
-- + the current day formating is customizable
|
||||
|
||||
local string = string
|
||||
--local print = print
|
||||
local tostring = tostring
|
||||
local os = os
|
||||
local capi = {
|
||||
mouse = mouse,
|
||||
screen = screen
|
||||
}
|
||||
local awful = require("awful")
|
||||
local naughty = require("naughty")
|
||||
module("calendar2")
|
||||
|
||||
local calendar = {}
|
||||
local current_day_format = "<u>%s</u>"
|
||||
|
||||
function displayMonth(month,year,weekStart)
|
||||
local t,wkSt=os.time{year=year, month=month+1, day=0},weekStart or 1
|
||||
local d=os.date("*t",t)
|
||||
local mthDays,stDay=d.day,(d.wday-d.day-wkSt+1)%7
|
||||
|
||||
--print(mthDays .."\n" .. stDay)
|
||||
local lines = " "
|
||||
|
||||
for x=0,6 do
|
||||
lines = lines .. os.date("%a ",os.time{year=2006,month=1,day=x+wkSt})
|
||||
end
|
||||
|
||||
lines = lines .. "\n" .. os.date(" %V",os.time{year=year,month=month,day=1})
|
||||
|
||||
local writeLine = 1
|
||||
while writeLine < (stDay + 1) do
|
||||
lines = lines .. " "
|
||||
writeLine = writeLine + 1
|
||||
end
|
||||
|
||||
for d=1,mthDays do
|
||||
local x = d
|
||||
local t = os.time{year=year,month=month,day=d}
|
||||
if writeLine == 8 then
|
||||
writeLine = 1
|
||||
lines = lines .. "\n" .. os.date(" %V",t)
|
||||
end
|
||||
if os.date("%Y-%m-%d") == os.date("%Y-%m-%d", t) then
|
||||
x = string.format(current_day_format, d)
|
||||
end
|
||||
if (#(tostring(d)) == 1) then
|
||||
x = " " .. x
|
||||
end
|
||||
lines = lines .. " " .. x
|
||||
writeLine = writeLine + 1
|
||||
end
|
||||
local header = os.date("%B %Y\n",os.time{year=year,month=month,day=1})
|
||||
|
||||
return header .. "\n" .. lines
|
||||
end
|
||||
|
||||
function switchNaughtyMonth(switchMonths)
|
||||
if (#calendar < 3) then return end
|
||||
local swMonths = switchMonths or 1
|
||||
calendar[1] = calendar[1] + swMonths
|
||||
calendar[3].box.widgets[2].text = string.format('<span font_desc="%s">%s</span>', "monospace", displayMonth(calendar[1], calendar[2], 2))
|
||||
end
|
||||
|
||||
function addCalendarToWidget(mywidget, custom_current_day_format)
|
||||
if custom_current_day_format then current_day_format = custom_current_day_format end
|
||||
|
||||
mywidget:add_signal('mouse::enter', function ()
|
||||
local month, year = os.date('%m'), os.date('%Y')
|
||||
calendar = { month, year,
|
||||
naughty.notify({
|
||||
text = string.format('<span font_desc="%s">%s</span>', "monospace", displayMonth(month, year, 2)),
|
||||
timeout = 0,
|
||||
hover_timeout = 0.5,
|
||||
screen = capi.mouse.screen
|
||||
})
|
||||
}
|
||||
end)
|
||||
mywidget:add_signal('mouse::leave', function () naughty.destroy(calendar[3]) end)
|
||||
|
||||
mywidget:buttons(awful.util.table.join(
|
||||
awful.button({ }, 1, function()
|
||||
switchNaughtyMonth(-1)
|
||||
end),
|
||||
awful.button({ }, 3, function()
|
||||
switchNaughtyMonth(1)
|
||||
end),
|
||||
awful.button({ }, 4, function()
|
||||
switchNaughtyMonth(-1)
|
||||
end),
|
||||
awful.button({ }, 5, function()
|
||||
switchNaughtyMonth(1)
|
||||
end),
|
||||
awful.button({ 'Shift' }, 1, function()
|
||||
switchNaughtyMonth(-12)
|
||||
end),
|
||||
awful.button({ 'Shift' }, 3, function()
|
||||
switchNaughtyMonth(12)
|
||||
end),
|
||||
awful.button({ 'Shift' }, 4, function()
|
||||
switchNaughtyMonth(-12)
|
||||
end),
|
||||
awful.button({ 'Shift' }, 5, function()
|
||||
switchNaughtyMonth(12)
|
||||
end)
|
||||
))
|
||||
end
|
||||
|
134
awesome/widgets/diskusage.lua
Normal file
134
awesome/widgets/diskusage.lua
Normal file
|
@ -0,0 +1,134 @@
|
|||
-- @author Peter J. Kranz (Absurd-Mind, peter@myref.net)
|
||||
-- Any questions, criticism or praise just drop me an email
|
||||
|
||||
-- {{{ init environment
|
||||
local M = {}
|
||||
local capi = {
|
||||
mouse = mouse,
|
||||
screen = screen
|
||||
}
|
||||
units = {"KB", "MB", "GB", "TB", "PB", "EB"}
|
||||
local usage = {}
|
||||
-- }}}
|
||||
|
||||
-- {{{ local functions
|
||||
-- {{{ Unit formatter
|
||||
-- formats a value to the corresponding unit
|
||||
local function uformat(value)
|
||||
local ret = tonumber(value)
|
||||
for i, u in pairs(units) do
|
||||
if ret < 1024 then
|
||||
return string.format("%.1f" .. u, ret)
|
||||
end
|
||||
ret = ret / 1024;
|
||||
end
|
||||
return "N/A"
|
||||
end
|
||||
-- }}}
|
||||
|
||||
-- {{{ getData
|
||||
-- gets the required data from df
|
||||
local function getData(onlyLocal)
|
||||
-- Fallback to listing local filesystems
|
||||
local warg = ""
|
||||
if onlyLocal == true then
|
||||
warg = "-l"
|
||||
end
|
||||
|
||||
local fs_info = {} -- Get data from df
|
||||
local f = io.popen("LC_ALL=C df -kP " .. warg)
|
||||
|
||||
for line in f:lines() do -- Match: (size) (used)(avail)(use%) (mount)
|
||||
local s = string.match(line, "^.-[%s]([%d]+)")
|
||||
local u,a,p = string.match(line, "([%d]+)[%D]+([%d]+)[%D]+([%d]+)%%")
|
||||
local m = string.match(line, "%%[%s]([%p%w]+)")
|
||||
|
||||
if u and m then -- Handle 1st line and broken regexp
|
||||
fs_info[m] = {}
|
||||
fs_info[m]["size"] = s
|
||||
fs_info[m]["used"] = u
|
||||
fs_info[m]["avail"] = a
|
||||
fs_info[m]["used_p"] = tonumber(p)
|
||||
fs_info[m]["avail_p"] = 100 - tonumber(p)
|
||||
end
|
||||
end
|
||||
f:close()
|
||||
return fs_info
|
||||
end
|
||||
-- }}}
|
||||
|
||||
-- {{{ display
|
||||
-- formats the lines for the notify
|
||||
local function display(orange, red, onlyLocal)
|
||||
data = getData(onlyLocal)
|
||||
local lines = "<u>diskusage:</u>\n"
|
||||
|
||||
local longest = 0
|
||||
local longestSize = 0;
|
||||
local longestUsed = 0;
|
||||
for i, m in pairs(data) do
|
||||
if i:len() > longest then
|
||||
longest = i:len()
|
||||
end
|
||||
|
||||
local s = uformat(m["size"])
|
||||
if s:len() > longestSize then
|
||||
longestSize = s:len()
|
||||
end
|
||||
|
||||
local u = uformat(m["used"])
|
||||
if u:len() > longestUsed then
|
||||
longestUsed = u:len()
|
||||
end
|
||||
end
|
||||
longest = longest + 8
|
||||
|
||||
for i, m in pairs(data) do
|
||||
local u = uformat(m["used"])
|
||||
local s = uformat(m["size"])
|
||||
|
||||
if m["used_p"] >= red then
|
||||
lines = lines .. "<span color='red'>"
|
||||
elseif m["used_p"] >= orange then
|
||||
lines = lines .. "<span color='orange'>"
|
||||
else
|
||||
lines = lines .. "<span color='green'>"
|
||||
end
|
||||
|
||||
lines = lines
|
||||
.. "\n"
|
||||
.. i
|
||||
.. string.rep(" ", longest + longestSize - i:len() - u:len())
|
||||
.. u
|
||||
.. " / "
|
||||
.. s
|
||||
.. string.rep(" ", longestUsed - s:len())
|
||||
.. " ("
|
||||
.. m["used_p"]
|
||||
.. "%)</span>"
|
||||
end
|
||||
|
||||
return lines
|
||||
end
|
||||
-- }}}
|
||||
-- }}}
|
||||
|
||||
-- {{{ global functions
|
||||
function M.addToWidget(mywidget, orange, red, onlyLocal)
|
||||
|
||||
mywidget:add_signal('mouse::enter', function ()
|
||||
|
||||
usage = naughty.notify({
|
||||
text = string.format('<span font_desc="%s">%s</span>', "monospace", display(orange, red, onlyLocal)),
|
||||
timeout = 0,
|
||||
hover_timeout = 0.5,
|
||||
screen = capi.mouse.screen
|
||||
})
|
||||
|
||||
end)
|
||||
mywidget:add_signal('mouse::leave', function () naughty.destroy(usage) end)
|
||||
end
|
||||
-- }}}
|
||||
|
||||
return M
|
||||
|
58
awesome/widgets/power.lua
Normal file
58
awesome/widgets/power.lua
Normal file
|
@ -0,0 +1,58 @@
|
|||
local wibox = require("wibox")
|
||||
local awful = require("awful")
|
||||
|
||||
|
||||
powercfg = {}
|
||||
powercfg.widget = wibox.widget.textbox()
|
||||
powercfg.widget:set_align("right");
|
||||
|
||||
powercfg.update = function ()
|
||||
--local fd = io.popen("acpi | cut -d ':' -f 2")
|
||||
--local status = fd:read("*all")
|
||||
--fd:close()
|
||||
|
||||
--local power = tonumber(string.match(status, "%d+"))
|
||||
--stats = string.match(status,"(%s+),")
|
||||
-- local charging = false
|
||||
--
|
||||
--
|
||||
stats = '1'
|
||||
power = ''
|
||||
local colour = 'blue'
|
||||
-- -- colours (start and end)
|
||||
-- local sr, sg, sb = 0x3F,0x3F,0x3F
|
||||
-- local er, eg, eb = 0xDC, 0xDC, 0xDC
|
||||
--
|
||||
-- -- make colour
|
||||
-- local ir = math.floor(power * (er - sr) + sr)
|
||||
-- local ib = math.floor(power * (eg - sg) + sg)
|
||||
-- local ig = math.floor(power * (eb - sb) + sb)
|
||||
-- --interpol_colour = string.format("%.2x%.2x%.2x", sr, ig, sb)
|
||||
interpol_colour = '3f4f3f'
|
||||
--
|
||||
-- if charging then
|
||||
-- colour = 'green'
|
||||
-- elseif power < 50 then
|
||||
-- colour = 'yellow'
|
||||
-- elseif power < 25 then
|
||||
-- colour = 'orange'
|
||||
-- elseif power < 10 then
|
||||
-- colour = 'red'
|
||||
-- end
|
||||
--power = status
|
||||
|
||||
|
||||
text = "<span color='" .. colour .. "' background='#" .. interpol_colour .. "'> " .. power .. "% </span>" .. status
|
||||
|
||||
powercfg.widget.text = text
|
||||
powercfg.widget:set_markup(text)
|
||||
end
|
||||
|
||||
-- start updating it
|
||||
powercfg.update()
|
||||
-- start timer
|
||||
powercfg.timer = timer({ timeout = 1})
|
||||
powercfg.timer:connect_signal("timeout", function () powercfg.update() end)
|
||||
powercfg.timer:start()
|
||||
|
||||
return powercfg
|
77
awesome/widgets/volume.lua
Normal file
77
awesome/widgets/volume.lua
Normal file
|
@ -0,0 +1,77 @@
|
|||
-- Volume widget
|
||||
local awful = require("awful")
|
||||
local wibox = require("wibox")
|
||||
|
||||
volumecfg = {}
|
||||
volumecfg.channel = "Master"
|
||||
|
||||
volumecfg.widget = wibox.widget.textbox()
|
||||
volumecfg.widget:set_align("right")
|
||||
volumecfg.widget.name = 'volumecfg.widget'
|
||||
|
||||
volumecfg_t = awful.tooltip({ objects = { volumecfg.widget },})
|
||||
volumecfg_t:set_text("Volume")
|
||||
|
||||
-- command must start with a space!
|
||||
volumecfg.mixercommand = function (command)
|
||||
local fd = io.popen("amixer " .. command)
|
||||
local status = fd:read("*all")
|
||||
fd:close()
|
||||
|
||||
local volume = tonumber(string.match(status, "(%d?%d?%d)%%"))
|
||||
-- volume = string.format("% 3d", volume)
|
||||
status = string.match(status, "%[(o[^%]]*)%]")
|
||||
|
||||
-- starting colour
|
||||
local sr, sg, sb = 0x3F, 0x3F, 0x3F
|
||||
-- ending colour
|
||||
local er, eg, eb = 0xDC, 0xDC, 0xCC
|
||||
|
||||
if string.find(status, "on", 1, true) then
|
||||
color = 'grey'
|
||||
mute = '♪'
|
||||
else
|
||||
sr, sg, sb = 0xFF, 0x33, 0xAA
|
||||
color = 'red'
|
||||
mute = 'M'
|
||||
end
|
||||
|
||||
local ir = math.floor(volume/100 * (er - sr) + sr)
|
||||
local ig = math.floor(volume/100 * (eg - sg) + sg)
|
||||
local ib = math.floor(volume/100 * (eb - sb) + sb)
|
||||
interpol_colour = string.format("%.2x%.2x%.2x", sr, ig, sb)
|
||||
|
||||
volume = " <span color='" .. color .. "' background='#" .. interpol_colour .. "'> ".. mute .. math.floor(volume) .. "% </span>"
|
||||
-- volume = volume .. "%"
|
||||
|
||||
|
||||
volumecfg.widget.text = volume
|
||||
volumecfg.widget:set_markup(volume)
|
||||
|
||||
end
|
||||
volumecfg.update = function ()
|
||||
volumecfg.mixercommand(" sget " .. volumecfg.channel)
|
||||
end
|
||||
volumecfg.up = function ()
|
||||
volumecfg.mixercommand(" sset " .. volumecfg.channel .. " 1%+")
|
||||
end
|
||||
volumecfg.down = function ()
|
||||
volumecfg.mixercommand(" sset " .. volumecfg.channel .. " 1%-")
|
||||
end
|
||||
volumecfg.toggle = function ()
|
||||
volumecfg.mixercommand(" sset " .. volumecfg.channel .. " toggle")
|
||||
end
|
||||
volumecfg.widget:buttons(awful.util.table.join(
|
||||
awful.button({ }, 4, function () volumecfg.up() end),
|
||||
awful.button({ }, 5, function () volumecfg.down() end),
|
||||
awful.button({ }, 1, function () volumecfg.toggle() end),
|
||||
awful.button({ }, 3, function () os.execute("pavucontrol &") end)
|
||||
))
|
||||
-- start updating
|
||||
volumecfg.update()
|
||||
-- start timer
|
||||
mytimer = timer({ timeout = 1 })
|
||||
mytimer:connect_signal("timeout", function () volumecfg.update() end)
|
||||
mytimer:start()
|
||||
|
||||
return volumecfg
|
51
awesome/widgets/volume2.lua
Normal file
51
awesome/widgets/volume2.lua
Normal file
|
@ -0,0 +1,51 @@
|
|||
local wibox = require("wibox")
|
||||
local awful = require("awful")
|
||||
|
||||
volume_widget = wibox.widget.textbox()
|
||||
volume_widget:set_align("right")
|
||||
|
||||
function raise_volume()
|
||||
os.execute("amixer sset Master 1%+")
|
||||
end
|
||||
|
||||
function lower_volume ()
|
||||
os.execute("amixer sset Master 1%-")
|
||||
end
|
||||
|
||||
function toggle_volume ()
|
||||
os.execute("amixer sset Master toggle")
|
||||
end
|
||||
|
||||
function update_volume(widget)
|
||||
local fd = io.popen("amixer sget Master")
|
||||
local status = fd:read("*all")
|
||||
fd:close()
|
||||
|
||||
local volume = tonumber(string.match(status, "(%d?%d?%d)%%"))
|
||||
-- volume = string.format("% 3d", volume)
|
||||
|
||||
status = string.match(status, "%[(o[^%]]*)%]")
|
||||
|
||||
-- starting colour
|
||||
local sr, sg, sb = 0x3F, 0x3F, 0x3F
|
||||
-- ending colour
|
||||
local er, eg, eb = 0xDC, 0xDC, 0xCC
|
||||
|
||||
local ir = math.floor(volume/100 * (er - sr) + sr)
|
||||
local ig = math.floor(volume/100 * (eg - sg) + sg)
|
||||
local ib = math.floor(volume/100 * (eb - sb) + sb)
|
||||
interpol_colour = string.format("%.2x%.2x%.2x", sr, ig, sb)
|
||||
if string.find(status, "on", 1, true) then
|
||||
volume = " <span color='blue' background='#" .. interpol_colour .. "'> ".. math.floor(volume) .. "% </span>"
|
||||
else
|
||||
volume = " <span color='red' background='#" .. interpol_colour .. "'> M(".. math.floor(volume) .."%) </span>"
|
||||
end
|
||||
widget:set_markup(volume)
|
||||
end
|
||||
|
||||
|
||||
-- start updating
|
||||
update_volume(volume_widget)
|
||||
mytimer = timer({ timeout = 1 })
|
||||
mytimer:connect_signal("timeout", function () update_volume(volume_widget) end)
|
||||
mytimer:start()
|
Loading…
Add table
Add a link
Reference in a new issue