-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrc.lua
More file actions
197 lines (157 loc) · 4.6 KB
/
rc.lua
File metadata and controls
197 lines (157 loc) · 4.6 KB
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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
--
-- Brandon Thomas' Awesome Window Manager Configs
-- ----------------------------------------------
-- Comments, suggestions, and patches are welcome
-- * echelon@gmail/github
-- * http://posbl.org
--
--[[ ======================================
Load Awesome WM Libraries
====================================== --]]
require("awful") -- Standard awesome library
require("awful.autofocus")
require("awful.rules")
require("beautiful") -- Theme library
require("naughty") -- Notification library
require("error") -- Error notify (local)
socket = require("socket") -- XXX: Need socket lib!
--[[ ======================================
AWESOME CONFIGURATION
====================================== --]]
AWESOME_NUM_TAGS = 1
AWESOME_FONT = 'bitstream vera sans 10'
AWESOME_THEME = '/themes/molokai/theme.lua'
AWESOME_CONFDIR = awful.util.getdir('config')
HOSTNAME = socket.dns.gethostname()
HOMEDIR = os.getenv('HOME')
CONFDIR = awful.util.getdir('config') -- TODO: Deprecate
CMD_LOCK = 'xlock -mode rain'
modkey = 'Mod4'
TERMINAL = 'urxvt'
TERMINAL_CWD = 'urxvt -cd'
BROWSER = 'chrome'
BROWSER2 = 'firefox'
EDITOR = os.getenv('EDITOR') or 'vim'
EDITOR_CMD = TERMINAL .. ' -e ' .. EDITOR
WALLPAPER_DIR = HOMEDIR .. '/Images/wallpaper'
BATTERY_NAME = nil
MOUSE_HIDE_TIMEOUT = 10
MOUSE_HIDE_NOMOVE_COUNT = 2
--[[ ======================================
Per-machine configuration switch
====================================== --]]
if HOSTNAME == 'darwin' then
BROWSER = 'firefox'
AWESOME_FONT = 'droid sans mono 10.5'
AWESOME_NUM_TAGS = 12
elseif HOSTNAME == 'x120e' then
AWESOME_FONT = 'bitstream vera sans 12.5'
AWESOME_NUM_TAGS = 12
BATTERY_NAME = 'BAT1'
elseif HOSTNAME == 'vaiop' then
AWESOME_FONT = 'ubuntu 13'
AWESOME_NUM_TAGS = 4
BROWSER = 'chromium-browser'
BATTERY_NAME = 'BAT0'
end
-- Init theme
beautiful.init(AWESOME_CONFDIR .. AWESOME_THEME)
-- From tony's github repo 'awesome-config'
-- TODO: Read it in full, it has great examples.
local WALLPAPER_CMD = "find " .. WALLPAPER_DIR
.. " -type f -regextype posix-extended -iregex '.*(png|jpg)$' -print0"
.. " | shuf -n1 -z | xargs -0 feh --bg-scale"
-- Spawn one and only one of these processes
do
local cmds = {
"gnome-sound-applet",
"if [ $(pidof nm-applet | wc -w) -eq 0 ]; then nm-applet; fi",
}
for _,i in pairs(cmds) do
awful.util.spawn_with_shell(i)
end
end
-- Table of layouts.
-- Order matters for awful.layout.inc
-- removed frivolous/redundant ones
layouts = {
awful.layout.suit.fair,
awful.layout.suit.tile,
awful.layout.suit.tile.top,
awful.layout.suit.fair.horizontal,
awful.layout.suit.spiral.dwindle,
}
if HOSTNAME == 'darwin' then
layouts = {
awful.layout.suit.tile.right,
awful.layout.suit.tile.bottom,
awful.layout.suit.spiral,
awful.layout.suit.fair.horizontal,
}
end
-- Build a tag table which hold all screen tags.
-- Each screen has its own tag table.
tags = {}
for s = 1, screen.count() do
local table = {}
for t = 1, AWESOME_NUM_TAGS do
table[t] = t
end
tags[s] = awful.tag(table, s, layouts[1])
end
-- REQUIRE EXTERNAL CONFIGS
require("topbar")
require("keybindings")
require("rules")
require("signals")
-- Last known coordinates of the mouse
mouseLastCoords = {x=0, y=0}
-- Setup mouse hiding timer
mouseTimerCount = 0 -- Number of times mouse hasn't moved
mouseTimer = timer { timeout = MOUSE_HIDE_TIMEOUT }
mouseTimer:add_signal("timeout", function()
-- Only move if hasn't been moved much.
local cur = mouse.coords()
if math.abs(cur.x - mouseLastCoords.x) < 2
and math.abs(cur.y - mouseLastCoords.y) < 2 then
mouseTimerCount = mouseTimerCount + 1
else
mouseTimerCount = 0
end
mouseLastCoords.x = cur.x
mouseLastCoords.y = cur.y
if mouseTimerCount >= MOUSE_HIDE_NOMOVE_COUNT then
mouse.coords({x=9000, y=9000})
mouseTimerCount = 0
end
-- Stop timer (so no multiple instances running)
mouseTimer:stop()
mouseTimer.timeout = MOUSE_HIDE_TIMEOUT
mouseTimer:start()
end)
mouseTimer:start()
-- Wallpaper timer
-- Again, from tony's repo
x = 0
mytimer = timer { timeout = x }
mytimer:add_signal("timeout", function()
-- Wallpaper randomization timers
-- TODO: Move to config options above.
local min = 5 * 60
local max = 15 * 60
-- Randomly choose wallpaper
--[[ -- File exists check fails for some unknown reason.
if file_exists(wallpaper_dir) and whereis_app('feh') then
battext.text = "File exists"
os.execute(wallpaper_cmd)
end
--]]
os.execute(WALLPAPER_CMD)
-- Stop timer (so no multiple instances running)
mytimer:stop()
-- Interval for new wallpaper
x = math.random(min, max)
mytimer.timeout = x
mytimer:start()
end)
mytimer:start()