-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathawconf.functions.lua
159 lines (127 loc) · 3.36 KB
/
awconf.functions.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
-- file: awconf.functions.lua
-- ********************
-- Helper Functions
-- ********************
io.stderr:write('\t--> Processing awconf.functions.lua ...\n')
-- The awesome calandar {{{
local calendar = nil
local offset = 0
function remove_calendar()
if calendar ~= nil then
naughty.destroy(calendar)
calendar = nil
offset = 0
end
end
function add_calendar(inc_offset)
local save_offset = offset
remove_calendar()
offset = save_offset + inc_offset
local datespec = os.date("*t")
datespec = datespec.year * 12 + datespec.month - 1 + offset
datespec = (datespec % 12 + 1) .. " " .. math.floor(datespec / 12)
local cal = awful.util.pread("cal -m " .. datespec)
cal = string.gsub(cal, "^%s*(.-)%s*$", "%1")
calendar = naughty.notify({
text = string.format('<span font_desc="%s">%s</span>', "monospace", os.date("%a, %d %B %Y") .. "\n" .. cal),
timeout = 0, hover_timeout = 0.5,
width = 165,
})
end
-- }}}
-- The Autostartfkt {{{
function autostart(progtable)
local filepath
local aweruns
filepath = '/tmp/awerun'
mfile = io.open(filepath , "r")
aweruns = mfile:read()
mfile:close()
if aweruns == "false" then
for i in ipairs(progtable) do
os.execute(progtable[i])
end
mfile = io.open(filepath , "w+")
mfile:write("true \n")
mfile:flush()
mfile:close()
naughty.notify({title = "X", text = "X Restart Detected", timeout = 10})
else
naughty.notify({title = "NOX", text = "No X Restart Detected", timeout = 10})
end
--naughty.notify({title = "X", text = aweruns, timeout = 10})
end
--}}}y
-- {{{ warptofocus(force)
function warptofocus(force)
--if not force and (not client.focus or awful.mouse.client_under_pointer() == client.focus or
-- awful.layout.get(client.focus.screen) == awful.layout.suit.magnifier) then
-- return
--end
local g = client.focus:geometry()
g.x = g.x + 10
g.y = g.y + 10
mouse.coords(g)
end
-- }}}
-- restore-fkt {{{
-- function save the focused tag and screen
-- argumets - tagtable,screencount
function save_session(sc)
local s
local t
-- open file to save
local file = io.open(awful.util.getdir("config") .. "/restore" , "w+")
-- find out selected screen
for s = 1,sc do
end
end
-- }}}
-- sig_viewnext_wo {{{
function sig_viewnext_wo()
-- get idx of selected tag
local c = 1
local scr = mouse.screen
for i,v in ipairs(tags[scr]) do
if v == awful.tag.selected(scr) then break
else c = c + 1 end
end
if c == # tags[scr] then
awful.screen.focus(1)
awful.tag.viewonly(tags[mouse.screen][1])
else
awful.tag.viewnext()
end
end
function sig_viewprev_wo()
-- get idx of selected tag
local c = 1
local scr = mouse.screen
local max
for i,v in ipairs(tags[scr]) do
if v == awful.tag.selected(scr) then break
else c = c + 1 end
end
if c == 1 then
awful.screen.focus(-1)
scr = mouse.screen
max = # tags[scr]
awful.tag.viewonly(tags[scr][max])
else
awful.tag.viewprev()
end
end
-- }}}
-- changevol() {{{
function vol_change(value)
cur = io.popen("amixer get DAC,0 | grep dB | cut -d \" \" -f 4"):read("*n")
n = cur + value
os.execute("amixer set DAC,0 " .. n)
os.execute("amixer set DAC,1 " .. n)
-- set widget text
volumewidget.text = n
end
function vol_get()
return io.popen("amixer get DAC,0 | grep dB | cut -d \" \" -f 4"):read("*n")
end
-- }}}