Advertisement
msjche

iMac11,3 ~/.config/awesome/rc.lua

Dec 21st, 2012
420
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 32.87 KB | None | 0 0
  1. -- Standard awesome library
  2. awful = require("awful")
  3. awful.autofocus = require("awful.autofocus")
  4. awful.rules = require("awful.rules")
  5. -- Theme handling library
  6. beautiful = require("beautiful")
  7. -- Notification library
  8. naughty = require("naughty")
  9. -- Hardware library
  10. vicious = require("vicious")
  11.  
  12. ------------------------------------------------------------------------------------
  13.  
  14. -- Run once
  15. lfs = require("lfs")
  16. -- {{{ Run programm once
  17. local function processwalker()
  18. local function yieldprocess()
  19. for dir in lfs.dir("/proc") do
  20. -- All directories in /proc containing a number, represent a process
  21. if tonumber(dir) ~= nil then
  22. local f, err = io.open("/proc/"..dir.."/cmdline")
  23. if f then
  24. local cmdline = f:read("*all")
  25. f:close()
  26. if cmdline ~= "" then
  27. coroutine.yield(cmdline)
  28. end
  29. end
  30. end
  31. end
  32. end
  33. return coroutine.wrap(yieldprocess)
  34. end
  35.  
  36. local function run_once(process, cmd)
  37. assert(type(process) == "string")
  38. local regex_killer = {
  39. ["+"] = "%+", ["-"] = "%-",
  40. ["*"] = "%*", ["?"] = "%?" }
  41.  
  42. for p in processwalker() do
  43. if p:find(process:gsub("[-+?*]", regex_killer)) then
  44. return
  45. end
  46. end
  47. return awful.util.spawn(cmd or process)
  48. end
  49. -- }}}
  50.  
  51. run_once("compton","-no-splash")
  52. run_once("insync","-no-splash")
  53. run_once("xscreensaver","-no-splash")
  54. run_once("ubuntuone-launch")
  55. --run_once("volumeicon")
  56. --run_once("bitcoin-qt")
  57. --run_once("conky")
  58. run_once("dropboxd","-no-splash")
  59. --run_once("pidgin",nil,nil,2)
  60. --run_once("wicd-client",nil,"/usr/bin/python2 -O /usr/share/wicd/gtk/wicd-client.py")
  61. --run_once("pgl","-no-splash", 6)
  62. --run_once("tor-browser-en","-no-splash",6)
  63.  
  64. ------------------------------------------------------------------------------------
  65.  
  66. -- {{{ Error handling
  67. -- Check if awesome encountered an error during startup and fell back to
  68. -- another config (This code will only ever execute for the fallback config)
  69. if awesome.startup_errors then
  70. naughty.notify({ preset = naughty.config.presets.critical,
  71. title = "Oops, there were errors during startup!",
  72. text = awesome.startup_errors })
  73. end
  74.  
  75. -- Handle runtime errors after startup
  76. do
  77. local in_error = false
  78. awesome.add_signal("debug::error", function (err)
  79. -- Make sure we don't go into an endless error loop
  80. if in_error then return end
  81. in_error = true
  82.  
  83. naughty.notify({ preset = naughty.config.presets.critical,
  84. title = "Oops, an error happened!",
  85. text = err })
  86. in_error = false
  87. end)
  88. end
  89. -- }}}
  90.  
  91. -- {{{ Variable definitions
  92. -- Themes define colours, icons, and wallpapers
  93. --beautiful.init("/usr/share/awesome/themes/default/theme.lua")
  94. beautiful.init(awful.util.getdir("config") .. "/themes/dust/theme.lua")
  95.  
  96.  
  97.  
  98. -- This is used later as the default terminal and editor to run.
  99. terminal = "gnome-terminal"
  100. editor = os.getenv("EDITOR") or "nano"
  101. editor_cmd = terminal .. " -e " .. editor
  102.  
  103. -- Default modkey.
  104. -- Usually, Mod4 is the key with a logo between Control and Alt.
  105. -- If you do not like this or do not have such a key,
  106. -- I suggest you to remap Mod4 to another key using xmodmap or other tools.
  107. -- However, you can use another modifier like Mod1, but it may interact with others.
  108. modkey = "Mod4"
  109.  
  110. -- Table of layouts to cover with awful.layout.inc, order matters.
  111. layouts =
  112. {
  113. awful.layout.suit.floating,
  114. awful.layout.suit.tile,
  115. awful.layout.suit.tile.left,
  116. awful.layout.suit.tile.bottom,
  117. awful.layout.suit.floating,
  118. awful.layout.suit.tile.top,
  119. awful.layout.suit.spiral,
  120. awful.layout.suit.spiral.dwindle,
  121. awful.layout.suit.fair,
  122. awful.layout.suit.fair.horizontal,
  123. awful.layout.suit.max,
  124. awful.layout.suit.max.fullscreen,
  125. awful.layout.suit.magnifier
  126. }
  127. -- }}}
  128.  
  129. -- {{{ Tags
  130. -- Define a tag table which hold all screen tags.
  131. tags = {
  132. names = {"☣","☢","ツ","✖","⚡","✉","♬","✇","☠"},
  133. -- names = {"main","web","devel","rss","twit","irc","gen","music","movies","rrrrr"},
  134. layout = {layouts[1],layouts[13],layouts[1],layouts[1],layouts[1],layouts[1],layouts[1],layouts[13],layouts[1]},
  135. icons = {"","","","","","","","","",""}
  136. }
  137. for s = 1, screen.count() do
  138. -- Each screen has its own tag table.
  139. tags[s] = awful.tag(tags.names, s, tags.layout)
  140. awful.tag.seticon(tags.icons[1],tags[s][1])
  141. awful.tag.seticon(tags.icons[2],tags[s][2])
  142. awful.tag.seticon(tags.icons[3],tags[s][3])
  143. awful.tag.seticon(tags.icons[4],tags[s][4])
  144. awful.tag.seticon(tags.icons[5],tags[s][5])
  145. awful.tag.seticon(tags.icons[6],tags[s][6])
  146. awful.tag.seticon(tags.icons[7],tags[s][7])
  147. awful.tag.seticon(tags.icons[8],tags[s][8])
  148. awful.tag.seticon(tags.icons[9],tags[s][9])
  149. awful.tag.seticon(tags.icons[10],tags[s][10])
  150. end
  151.  
  152. -- make tag list bigger
  153. theme.taglist_font = "Sans Bold 20"
  154.  
  155. -- }}}
  156. --for a = 1, 10, 1 do
  157. --awful.tag.setproperty(tags[1][a], "icon_only", 1)
  158. --end
  159.  
  160. -- {{{ Tags
  161. -- Define a tag table which hold all screen tags.
  162. --tags = {}
  163. --for s = 1, screen.count() do
  164. -- -- Each screen has its own tag table.
  165. ---- tags[s] = awful.tag({ "alpha", "beta", "gamma", "delta", "epsilon", "zeta", "eta", "theta", "iota" }, s, layouts[1])
  166. -- tags[s] = awful.tag({ "web_I", "web_II", "term", "files", "devel", "irc", "music", "movies", "pirate" }, s, layouts[1])
  167. --end
  168. -- }}}
  169.  
  170.  
  171. -- {{{ Menu
  172. -- Create a laucher widget and a main menu
  173. myawesomemenu = {
  174. -- { "manual", terminal .. " -e man awesome" },
  175. -- { "edit config", editor_cmd .. " " .. awesome.conffile },
  176. { "Restart Awesome", awesome.restart },
  177. { "Suspend","gksu dbus-suspend" },
  178. { "Log out", awesome.quit },
  179. { "Shut Down", "gksu shutdown -P now" }
  180. }
  181.  
  182. windowsmenu = {
  183. { "Word", "/home/msjche/bin/winword", "/home/msjche/.config/awesome/Icons/Word-icon.png" },
  184. { "Excel", "/home/msjche/bin/excel", "/home/msjche/.config/awesome/Icons/Excel-icon.png" },
  185. { "PowerPoint", "/home/msjche/bin/powerpnt", "/home/msjche/.config/awesome/Icons/PowerPoint-icon.png" }
  186. }
  187.  
  188. appsmenu = {
  189. { "Devede", "devede", "/home/msjche/.config/awesome/Icons/devede-icon.png" },
  190. { "GEdit", "gedit", "/home/msjche/.config/awesome/Icons/gedit-icon.png" },
  191. { "GIMP", "gimp", "/home/msjche/.config/awesome/Icons/Gimp-icon.png" },
  192. { "Google Earth", "google-earth", "/home/msjche/.config/awesome/Icons/google_earth.png" },
  193. { "Guvcview", "guvcview", "/home/msjche/.config/awesome/Icons/guvcview-icon.png" },
  194. { "K3B", "k3b", "/home/msjche/.config/awesome/Icons/k3b-icon.png" },
  195. { "Kdenlive", "kdenlive", "/home/msjche/.config/awesome/Icons/kdenlive_icon.png" },
  196. { "Minitube", "minitube", "/home/msjche/.config/awesome/Icons/minitube-icon.png" },
  197. { "Rhythmbox", "rhythmbox", "/home/msjche/.config/awesome/Icons/rhythmbox.png" },
  198. { "Shotwell", "shotwell", "/home/msjche/.config/awesome/Icons/shotwell-icon.png" },
  199. { "Skype", "skype", "/home/msjche/.config/awesome/Icons/Apps-Skype-icon.png" },
  200. { "Virtualbox", "virtualbox", "/home/msjche/.config/awesome/Icons/virtualbox-icon.png" }
  201. }
  202.  
  203. mymainmenu = awful.menu({ items = {
  204. { "awesome", myawesomemenu, "/home/msjche/.config/awesome/Icons/arch.png" },
  205. { "Pavucontrol", "pavucontrol", "/home/msjche/.config/awesome/Icons/volume-icon.png" },
  206. { "Thunar", "thunar", "/home/msjche/.config/awesome/Icons/thunar-icon.png" },
  207. { "Root Thunar", "gksu thunar", "/home/msjche/.config/awesome/Icons/thunar-icon.png" },
  208. { "SpaceFM", "spacefm", "/home/msjche/.config/awesome/Icons/spacefm.png" },
  209. { "Root Nautilus", "gksu nautilus", "/home/msjche/.config/awesome/Icons/nautilus.png" },
  210. { "Sublime", "/opt/sublime-text/sublime_text", "/home/msjche/.config/awesome/Icons/sublime-icon.png" },
  211. { "Firefox", "firefox", "/home/msjche/.config/awesome/Icons/firefox-icon.png" },
  212. { "Luakit", "luakit", "/home/msjche/.config/awesome/Icons/Lua-Logo.png" },
  213. { "Iron", "iron", "/home/msjche/.config/awesome/Icons/iron-browser-icon.png" },
  214. { "Tor", "tor-browser-en", "/home/msjche/.config/awesome/Icons/Vidalia_icon.png" },
  215. { "Peer Guardian", "pglgui", "/home/msjche/.config/awesome/Icons/PeerGuardian_icon.png" },
  216. { "Deluge", "deluge", "/home/msjche/.config/awesome/Icons/Deluge_icon.png" },
  217. { "Appearance", "lxappearance", "/home/msjche/.config/awesome/Icons/appearance-icon.png" },
  218. { "Libre Office", " libreoffice", "/home/msjche/.config/awesome/Icons/libreoffice.png" },
  219. { "Applications", appsmenu, "/home/msjche/.config/awesome/Icons/apps-icon.png" },
  220. { "MS Office", windowsmenu, "/home/msjche/.config/awesome/Icons/Windows-icon.png" },
  221. { "Record Desktop", "gtk-recordMyDesktop", "/home/msjche/.config/awesome/Icons/record-icon.png" },
  222. { "Screen Shot", "gscreenshot", "/home/msjche/.config/awesome/Icons/camera-icon.png" }
  223. }
  224. })
  225.  
  226. mylauncher = awful.widget.launcher({ image = image(beautiful.awesome_icon),
  227. menu = mymainmenu })
  228. -- }}}
  229.  
  230. --------------------------------------------------------------------------------------------------------------------------------
  231.  
  232. -- {{{ Wibox (Top)
  233.  
  234. -- Create a textclock widget
  235. mytextclock = awful.widget.textclock({ align = "right" })
  236.  
  237. -- Calendar widget to attach to the textclock
  238. require('calendar2')
  239. calendar2.addCalendarToWidget(mytextclock)
  240.  
  241. -- Create a systray
  242. mysystray = widget({ type = "systray" })
  243.  
  244. spacetxt = widget({ type = "textbox" })
  245. spacetxt.text = " || "
  246.  
  247. space = widget({ type = "textbox" })
  248. space.text = " "
  249.  
  250. spaceimg = widget({ type = "imagebox" })
  251. spaceimg.image = image("/home/msjche/.config/awesome/Icons/Awesome/space.png")
  252.  
  253. music = widget({ type = "textbox" })
  254. music.text = " ♫ "
  255. --------------------------------------------------------------------------------------------
  256.  
  257. -- Volume
  258.  
  259. volimg = widget({ type = "imagebox" })
  260. volimg.image = image("/home/msjche/.config/awesome/Icons/Awesome/volume.png")
  261.  
  262. volumecfg = {}
  263. volumecfg.cardid = 0
  264. volumecfg.channel = "Master"
  265. volumecfg.widget = widget({ type = "textbox", name = "volumecfg.widget", align = "right" })
  266.  
  267. volumecfg_t = awful.tooltip({ objects = { volumecfg.widget },})
  268. volumecfg_t:set_text("Volume")
  269.  
  270. -- command must start with a space!
  271. volumecfg.mixercommand = function (command)
  272. local fd = io.popen("amixer -c " .. volumecfg.cardid .. command)
  273. local status = fd:read("*all")
  274. fd:close()
  275.  
  276. local volume = string.match(status, "(%d?%d?%d)%%")
  277. volume = string.format("% 3d", volume)
  278. status = string.match(status, "%[(o[^%]]*)%]")
  279. if string.find(status, "on", 1, true) then
  280. volume = volume .. "%"
  281. else
  282. volume = volume .. "M"
  283. end
  284. volumecfg.widget.text = volume
  285. end
  286. volumecfg.update = function ()
  287. volumecfg.mixercommand(" sget " .. volumecfg.channel)
  288. end
  289. volumecfg.up = function ()
  290. volumecfg.mixercommand(" sset " .. volumecfg.channel .. " 1%+")
  291. end
  292. volumecfg.down = function ()
  293. volumecfg.mixercommand(" sset " .. volumecfg.channel .. " 1%-")
  294. end
  295. volumecfg.toggle = function ()
  296. volumecfg.mixercommand(" sset " .. volumecfg.channel .. " toggle")
  297. end
  298. volumecfg.widget:buttons({
  299. button({ }, 4, function () volumecfg.up() end),
  300. button({ }, 5, function () volumecfg.down() end),
  301. button({ }, 1, function () volumecfg.toggle() end)
  302. })
  303. volumecfg.update()
  304.  
  305. --------------------------------------------------------------------------------------------
  306.  
  307. -- MPD
  308.  
  309. mpdimg = widget({ type = "imagebox" })
  310. mpdimg.image = image("/home/msjche/.config/awesome/Icons/Awesome/music.png")
  311.  
  312. mpdwidget = widget({ type = "textbox" })
  313. vicious.register(mpdwidget, vicious.widgets.mpd,
  314. function (widget, args)
  315. if args["{state}"] == "Stop" then
  316. return " - "
  317. else
  318. return args["{Artist}"]..' - '.. args["{Title}"]
  319. end
  320. end, 10)
  321.  
  322. --------------------------------------------------------------------------------------------
  323.  
  324. -- Weather
  325.  
  326. weatherimg = widget({ type = "imagebox" })
  327. weatherimg.image = image("/home/msjche/.config/awesome/Icons/Awesome/weather.png")
  328.  
  329. -- Weather widget
  330. weatherwidget = widget({ type = "textbox" })
  331. weather_t = awful.tooltip({ objects = { weatherwidget },})
  332.  
  333. vicious.register(weatherwidget, vicious.widgets.weather,
  334. function (widget, args)
  335. weather_t:set_text("City: " .. args["{city}"] .."\nWind: " .. args["{windkmh}"] .. "km/h " .. args["{wind}"] .. "\nSky: " .. args["{sky}"] .. "\nHumidity: " .. args["{humid}"] .. "%")
  336. return args["{tempf}"] .. " F"
  337. end, 1800, "KCCR")
  338. --'1800': check every 30 minutes.
  339. --'': the WC, CA ICAO code.
  340.  
  341. --------------------------------------------------------------------------------------------
  342.  
  343. -- Memory
  344.  
  345. memimg = widget({ type = "imagebox" })
  346. memimg.image = image("/home/msjche/.config/awesome/Icons/Awesome/memory.png")
  347.  
  348. memwidgettxt = widget({ type = "textbox" })
  349. vicious.register(memwidgettxt, vicious.widgets.mem, "$2 MB", 10)
  350.  
  351. -- Memory widget
  352. memwidget = awful.widget.progressbar()
  353. memwidget:set_width(12)
  354. memwidget:set_vertical(true)
  355. memwidget:set_height(22)
  356. memwidget:set_background_color("#494B4F")
  357. --memwidget:set_border_color("#494B4F")
  358. memwidget:set_color("#D5C9C9")
  359. memwidget:set_gradient_colors({ "#D5C9C9", "#D5C9C9", "#D5C9C9" })
  360. vicious.register(memwidget, vicious.widgets.mem, "$1")
  361.  
  362. --------------------------------------------------------------------------------------------
  363.  
  364. -- HD
  365.  
  366. -- Disk usage widget
  367. diskwidget = widget({ type = 'imagebox' })
  368. diskwidget.image = image("/home/msjche/.config/awesome/Icons/Awesome/harddrive.png")
  369. disk = require("diskusage")
  370. -- the first argument is the widget to trigger the diskusage
  371. -- the second/third is the percentage at which a line gets orange/red
  372. -- true = show only local filesystems
  373. disk.addToWidget(diskwidget, 75, 90, false)
  374.  
  375. hdwidget = widget({ type = "textbox" })
  376. vicious.register(hdwidget, vicious.widgets.fs, "${/ used_p}%", 15)
  377.  
  378. hdwidgetg = awful.widget.progressbar()
  379. hdwidgetg:set_width(12)
  380. hdwidgetg:set_vertical(true)
  381. hdwidgetg:set_height(22)
  382. hdwidgetg:set_background_color("#494B4F")
  383. --hdwidgetg:set_border_color("#494B4F")
  384. hdwidgetg:set_color("#D5C9C9")
  385. hdwidgetg:set_gradient_colors({ "#D5C9C9", "#D5C9C9", "#D5C9C9" })
  386. vicious.register(hdwidgetg, vicious.widgets.fs, "${/ used_p}", 120, 60)
  387.  
  388. --------------------------------------------------------------------------------------------
  389.  
  390. -- CPU
  391.  
  392. cpuimg = widget({ type = "imagebox" })
  393. cpuimg.image = image("/home/msjche/.config/awesome/Icons/Awesome/cpu.png")
  394.  
  395. ctext = widget({ type = "textbox"})
  396. cgraph = awful.widget.graph()
  397. cgraph:set_width(60):set_height(22)
  398. cgraph:set_stack(true):set_max_value(400)
  399. cgraph:set_background_color("#494B4F")
  400. -- cgraph1:set_border_color("#494B4F")
  401. cgraph:set_stack_colors({ "#E0D4D4", "#ED4F4F", "#5A4FED", "#55FB41" })
  402. vicious.register(ctext, vicious.widgets.cpu,
  403. function (widget, args)
  404. cgraph:add_value(args[2], 1) -- Core 1
  405. cgraph:add_value(args[3], 2) -- Core 2
  406. cgraph:add_value(args[4], 3) -- Core 3
  407. cgraph:add_value(args[5], 4) -- Core 4
  408. end, 1)
  409.  
  410. --------------------------------------------------------------------------------------------
  411.  
  412. -- Network
  413.  
  414. upimg = widget({ type = "imagebox" })
  415. upimg.image = image("/home/msjche/.config/awesome/Icons/Awesome/up.png")
  416.  
  417. downimg = widget({ type = "imagebox" })
  418. downimg.image = image("/home/msjche/.config/awesome/Icons/Awesome/down.png")
  419.  
  420. -- Network eth0
  421. ethimg = widget({ type = "imagebox" })
  422. ethimg.image = image("/home/msjche/.config/awesome/Icons/Awesome/ethernet.png")
  423.  
  424. netwidgetet = widget({type = "textbox"})
  425. vicious.register(netwidgetet, vicious.widgets.net, '(${eth0 up_kb} up) / (${eth0 down_kb} dn) kps', 1 )
  426.  
  427. -- Network wlan0
  428.  
  429. wifiimg = widget({ type = "imagebox" })
  430. wifiimg.image = image("/home/msjche/.config/awesome/Icons/Awesome/wifi.png")
  431.  
  432. netwidgetwt = widget({type = "textbox"})
  433. vicious.register(netwidgetwt, vicious.widgets.net, '(${wlan0 up_kb} up) / (${wlan0 down_kb} dn) kps', 1 )
  434.  
  435. -- Wifi
  436. wifiwidget = widget({ type = "textbox" })
  437. vicious.register(wifiwidget, vicious.widgets.wifi, "\"${ssid}\" @ ${link}% - ", 10, "wlan0")
  438.  
  439.  
  440. -- Network eth0
  441. netgrapheth0d = awful.widget.graph()
  442. netgrapheth0d:set_width(45)
  443. netgrapheth0d:set_height(22)
  444. netgrapheth0d:set_background_color("#494B4F")
  445. netgrapheth0d:set_color("#D5C9C9")
  446. netgrapheth0d:set_gradient_colors({ "#B3EEFF", "#B3EEFF", "#B3EEFF" })
  447.  
  448. netgrapheth0d_t = awful.tooltip({ objects = { netgrapheth0d.widget },})
  449. vicious.register(netgrapheth0d, vicious.widgets.net,
  450. function (widget, args)
  451. netgrapheth0d_t:set_text("Ethernet download: " .. args["{eth0 down_kb}"] .. "kb/s")
  452. return args["{eth0 down_kb}"]
  453. end, 1 )
  454.  
  455. netgrapheth0u = awful.widget.graph()
  456. netgrapheth0u:set_width(45)
  457. netgrapheth0u:set_height(22)
  458. netgrapheth0u:set_background_color("#494B4F")
  459. netgrapheth0u:set_color("#D5C9C9")
  460. netgrapheth0u:set_gradient_colors({ "#B3EEFF", "#B3EEFF", "#B3EEFF" })
  461.  
  462. netgrapheth0u_t = awful.tooltip({ objects = { netgrapheth0u.widget },})
  463. vicious.register(netgrapheth0u, vicious.widgets.net,
  464. function (widget, args)
  465. netgrapheth0u_t:set_text("Ethernet upload: " .. args["{eth0 up_kb}"] .. "kb/s")
  466. return args["{eth0 up_kb}"]
  467. end, 1 )
  468.  
  469. -- Network wlan0
  470. netgraphwlan0d = awful.widget.graph()
  471. netgraphwlan0d:set_width(45)
  472. netgraphwlan0d:set_height(22)
  473. netgraphwlan0d:set_background_color("#494B4F")
  474. netgraphwlan0d:set_color("#D5C9C9")
  475. netgraphwlan0d:set_gradient_colors({ "#B3EEFF", "#B3EEFF", "#B3EEFF" })
  476.  
  477. netgraphwlan0d_t = awful.tooltip({ objects = { netgraphwlan0d.widget },})
  478. vicious.register(netgraphwlan0d, vicious.widgets.net,
  479. function (widget, args)
  480. netgraphwlan0d_t:set_text("Wifi download: " .. args["{wlan0 down_kb}"] .. "kb/s")
  481. return args["{wlan0 down_kb}"]
  482. end, 1 )
  483.  
  484. netgraphwlan0u = awful.widget.graph()
  485. netgraphwlan0u:set_width(45)
  486. netgraphwlan0u:set_height(22)
  487. netgraphwlan0u:set_background_color("#494B4F")
  488. netgraphwlan0u:set_color("#D5C9C9")
  489. netgraphwlan0u:set_gradient_colors({ "#B3EEFF", "#B3EEFF", "#B3EEFF" })
  490.  
  491. netgraphwlan0u_t = awful.tooltip({ objects = { netgraphwlan0u.widget },})
  492. vicious.register(netgraphwlan0u, vicious.widgets.net,
  493. function (widget, args)
  494. netgraphwlan0u_t:set_text("Wifi upload: " .. args["{wlan0 up_kb}"] .. "kb/s")
  495. return args["{wlan0 up_kb}"]
  496. end, 1 )
  497.  
  498. --------------------------------------------------------------------------------------------
  499.  
  500. -- Uptime
  501.  
  502. uptimeimg = widget({ type = "imagebox" })
  503. uptimeimg.image = image("/home/msjche/.config/awesome/Icons/Awesome/uptime.png")
  504.  
  505. uptimewidget = widget({ type = "textbox" })
  506. vicious.register(uptimewidget, vicious.widgets.uptime,
  507. function (widget, args)
  508. return string.format("%2dd %02d:%02d ", args[1], args[2], args[3])
  509. end, 61)
  510.  
  511. --------------------------------------------------------------------------------------------
  512.  
  513. -- Create a wibox for each screen and add it
  514. mywibox = {}
  515. mypromptbox = {}
  516. mylayoutbox = {}
  517. mytaglist = {}
  518. mytaglist.buttons = awful.util.table.join(
  519. awful.button({ }, 1, awful.tag.viewonly),
  520. awful.button({ modkey }, 1, awful.client.movetotag),
  521. awful.button({ }, 3, awful.tag.viewtoggle),
  522. awful.button({ modkey }, 3, awful.client.toggletag),
  523. awful.button({ }, 4, awful.tag.viewnext),
  524. awful.button({ }, 5, awful.tag.viewprev)
  525. )
  526. mytasklist = {}
  527. mytasklist.buttons = awful.util.table.join(
  528. awful.button({ }, 1, function (c)
  529. if c == client.focus then
  530. c.minimized = true
  531. else
  532. if not c:isvisible() then
  533. awful.tag.viewonly(c:tags()[1])
  534. end
  535. -- This will also un-minimize
  536. -- the client, if needed
  537. client.focus = c
  538. c:raise()
  539. end
  540. end),
  541. awful.button({ }, 3, function ()
  542. if instance then
  543. instance:hide()
  544. instance = nil
  545. else
  546. instance = awful.menu.clients({ width=250 })
  547. end
  548. end),
  549. awful.button({ }, 4, function ()
  550. awful.client.focus.byidx(1)
  551. if client.focus then client.focus:raise() end
  552. end),
  553. awful.button({ }, 5, function ()
  554. awful.client.focus.byidx(-1)
  555. if client.focus then client.focus:raise() end
  556. end))
  557.  
  558. for s = 1, screen.count() do
  559. -- Create a promptbox for each screen
  560. mypromptbox[s] = awful.widget.prompt({ layout = awful.widget.layout.horizontal.leftright })
  561. -- Create an imagebox widget which will contains an icon indicating which layout we're using.
  562. -- We need one layoutbox per screen.
  563. mylayoutbox[s] = awful.widget.layoutbox(s)
  564. mylayoutbox[s]:buttons(awful.util.table.join(
  565. awful.button({ }, 1, function () awful.layout.inc(layouts, 1) end),
  566. awful.button({ }, 3, function () awful.layout.inc(layouts, -1) end),
  567. awful.button({ }, 4, function () awful.layout.inc(layouts, 1) end),
  568. awful.button({ }, 5, function () awful.layout.inc(layouts, -1) end)))
  569. -- Create a taglist widget
  570. mytaglist[s] = awful.widget.taglist(s, awful.widget.taglist.label.all, mytaglist.buttons)
  571.  
  572. -- Create a tasklist widget
  573. mytasklist[s] = awful.widget.tasklist(function(c)
  574. return awful.widget.tasklist.label.currenttags(c, s)
  575. end, mytasklist.buttons)
  576.  
  577. -- Create the wibox
  578. mywibox[s] = awful.wibox({ position = "top", height = "24", screen = s })
  579.  
  580. -- Add widgets to the wibox - order matters
  581. mywibox[s].widgets = {
  582. {
  583. -- mylauncher,
  584. mytaglist[s],
  585. spacetxt,
  586. cpuimg,
  587. space,
  588. cgraph,
  589. spacetxt,
  590. diskwidget,
  591. space,
  592. hdwidgetg,
  593. spacetxt,
  594. memimg,
  595. space,
  596. memwidget,
  597. space,
  598. memwidgettxt,
  599. spacetxt,
  600. ethimg,
  601. space,
  602. netgrapheth0d,
  603. space,
  604. downimg,
  605. space,
  606. netgrapheth0u,
  607. space,
  608. upimg,
  609. spacetxt,
  610. wifiimg,
  611. space,
  612. netgraphwlan0d,
  613. space,
  614. downimg,
  615. space,
  616. netgraphwlan0u,
  617. space,
  618. upimg,
  619. spacetxt,
  620. mypromptbox[s],
  621. layout = awful.widget.layout.horizontal.leftright
  622. },
  623. mylayoutbox[s],
  624. space,
  625. mytextclock,
  626. spacetxt,
  627. uptimewidget,
  628. space,
  629. uptimeimg,
  630. spacetxt,
  631. s == 1 and mysystray or nil,
  632. spacetxt,
  633. weatherwidget,
  634. space,
  635. weatherimg,
  636. spacetxt,
  637. volumecfg.widget,
  638. space,
  639. volimg,
  640. spacetxt,
  641. mpdwidget,
  642. space,
  643. mpdimg,
  644. spacetxt,
  645. mytasklist[s],
  646. layout = awful.widget.layout.horizontal.rightleft
  647. }
  648. end
  649. -- }}}
  650.  
  651. --------------------------------------------------------------------------------------------------------------------------------
  652.  
  653. -- {{{ Mouse bindings
  654. root.buttons(awful.util.table.join(
  655. awful.button({ }, 3, function () mymainmenu:toggle() end),
  656. awful.button({ }, 4, awful.tag.viewnext),
  657. awful.button({ }, 5, awful.tag.viewprev)
  658. ))
  659. -- }}}
  660.  
  661. -- {{{ Key bindings
  662. globalkeys = awful.util.table.join(
  663. awful.key({ modkey, }, "Left", awful.tag.viewprev ),
  664. awful.key({ modkey, }, "Right", awful.tag.viewnext ),
  665. awful.key({ modkey, }, "Escape", awful.tag.history.restore),
  666.  
  667. awful.key({ modkey, }, "j",
  668. function ()
  669. awful.client.focus.byidx( 1)
  670. if client.focus then client.focus:raise() end
  671. end),
  672. awful.key({ modkey, }, "k",
  673. function ()
  674. awful.client.focus.byidx(-1)
  675. if client.focus then client.focus:raise() end
  676. end),
  677. awful.key({ modkey, }, "w", function () mymainmenu:show({keygrabber=true}) end),
  678.  
  679. -- Layout manipulation
  680. awful.key({ modkey, "Shift" }, "j", function () awful.client.swap.byidx( 1) end),
  681. awful.key({ modkey, "Shift" }, "k", function () awful.client.swap.byidx( -1) end),
  682. awful.key({ modkey, "Control" }, "j", function () awful.screen.focus_relative( 1) end),
  683. awful.key({ modkey, "Control" }, "k", function () awful.screen.focus_relative(-1) end),
  684. awful.key({ modkey, }, "u", awful.client.urgent.jumpto),
  685. awful.key({ modkey, }, "Tab",
  686. function ()
  687. awful.client.focus.history.previous()
  688. if client.focus then
  689. client.focus:raise()
  690. end
  691. end),
  692.  
  693. -- Standard program
  694. awful.key({ modkey, }, "Return", function () awful.util.spawn(terminal) end),
  695. awful.key({ modkey, "Control" }, "r", awesome.restart),
  696. awful.key({ modkey, "Shift" }, "q", awesome.quit),
  697.  
  698. awful.key({ modkey, }, "l", function () awful.tag.incmwfact( 0.05) end),
  699. awful.key({ modkey, }, "h", function () awful.tag.incmwfact(-0.05) end),
  700. awful.key({ modkey, "Shift" }, "h", function () awful.tag.incnmaster( 1) end),
  701. awful.key({ modkey, "Shift" }, "l", function () awful.tag.incnmaster(-1) end),
  702. awful.key({ modkey, "Control" }, "h", function () awful.tag.incncol( 1) end),
  703. awful.key({ modkey, "Control" }, "l", function () awful.tag.incncol(-1) end),
  704. awful.key({ modkey, }, "space", function () awful.layout.inc(layouts, 1) end),
  705. awful.key({ modkey, "Shift" }, "space", function () awful.layout.inc(layouts, -1) end),
  706.  
  707. awful.key({ modkey, "Control" }, "n", awful.client.restore),
  708.  
  709. -- Prompt
  710. awful.key({ modkey }, "r", function () mypromptbox[mouse.screen]:run() end),
  711.  
  712. awful.key({ modkey }, "x",
  713. function ()
  714. awful.prompt.run({ prompt = "Run Lua code: " },
  715. mypromptbox[mouse.screen].widget,
  716. awful.util.eval, nil,
  717. awful.util.getdir("cache") .. "/history_eval")
  718. end)
  719. )
  720.  
  721. clientkeys = awful.util.table.join(
  722. awful.key({ modkey, }, "f", function (c) c.fullscreen = not c.fullscreen end),
  723. awful.key({ modkey, "Shift" }, "c", function (c) c:kill() end),
  724. awful.key({ modkey, "Control" }, "space", awful.client.floating.toggle ),
  725. awful.key({ modkey, "Control" }, "Return", function (c) c:swap(awful.client.getmaster()) end),
  726. awful.key({ modkey, }, "o", awful.client.movetoscreen ),
  727. awful.key({ modkey, "Shift" }, "r", function (c) c:redraw() end),
  728. awful.key({ modkey, }, "t", function (c) c.ontop = not c.ontop end),
  729. awful.key({ modkey, }, "n",
  730. function (c)
  731. -- The client currently has the input focus, so it cannot be
  732. -- minimized, since minimized clients can't have the focus.
  733. c.minimized = true
  734. end),
  735. awful.key({ modkey, }, "m",
  736. function (c)
  737. c.maximized_horizontal = not c.maximized_horizontal
  738. c.maximized_vertical = not c.maximized_vertical
  739. end)
  740. )
  741.  
  742. -- Compute the maximum number of digit we need, limited to 9
  743. keynumber = 0
  744. for s = 1, screen.count() do
  745. keynumber = math.min(9, math.max(#tags[s], keynumber));
  746. end
  747.  
  748. -- Bind all key numbers to tags.
  749. -- Be careful: we use keycodes to make it works on any keyboard layout.
  750. -- This should map on the top row of your keyboard, usually 1 to 9.
  751. for i = 1, keynumber do
  752. globalkeys = awful.util.table.join(globalkeys,
  753. awful.key({ modkey }, "#" .. i + 9,
  754. function ()
  755. local screen = mouse.screen
  756. if tags[screen][i] then
  757. awful.tag.viewonly(tags[screen][i])
  758. end
  759. end),
  760. awful.key({ modkey, "Control" }, "#" .. i + 9,
  761. function ()
  762. local screen = mouse.screen
  763. if tags[screen][i] then
  764. awful.tag.viewtoggle(tags[screen][i])
  765. end
  766. end),
  767. awful.key({ modkey, "Shift" }, "#" .. i + 9,
  768. function ()
  769. if client.focus and tags[client.focus.screen][i] then
  770. awful.client.movetotag(tags[client.focus.screen][i])
  771. end
  772. end),
  773. awful.key({ modkey, "Control", "Shift" }, "#" .. i + 9,
  774. function ()
  775. if client.focus and tags[client.focus.screen][i] then
  776. awful.client.toggletag(tags[client.focus.screen][i])
  777. end
  778. end),
  779. awful.key({ }, "XF86AudioRaiseVolume", function () volumecfg.up(0) end),
  780. awful.key({ }, "XF86AudioLowerVolume", function () volumecfg.down(0) end),
  781. awful.key({ }, "XF86AudioMute", function () volumecfg.toggle() end))
  782.  
  783. end
  784.  
  785. clientbuttons = awful.util.table.join(
  786. awful.button({ }, 1, function (c) client.focus = c; c:raise() end),
  787. awful.button({ modkey }, 1, awful.mouse.client.move),
  788. awful.button({ modkey }, 3, awful.mouse.client.resize))
  789.  
  790. -- Set keys
  791. root.keys(globalkeys)
  792. -- }}}
  793.  
  794. -- {{{ Rules
  795. awful.rules.rules = {
  796. -- All clients will match this rule.
  797. { rule = { },
  798. properties = { border_width = beautiful.border_width,
  799. border_color = beautiful.border_normal,
  800. focus = true,
  801. keys = clientkeys,
  802. buttons = clientbuttons } },
  803. { rule = { class = "MPlayer" },
  804. properties = { floating = true } },
  805. { rule = { class = "pinentry" },
  806. properties = { floating = true } },
  807. { rule = { class = "gimp" },
  808. properties = { floating = true } },
  809. -- Set Firefox to always map on tags number 2 of screen 1.
  810. -- { rule = { class = "Firefox" },
  811. -- properties = { tag = tags[1][2] } },
  812. }
  813. -- }}}
  814.  
  815. -- {{{ Signals
  816. -- Signal function to execute when a new client appears.
  817. client.add_signal("manage", function (c, startup)
  818. -- Add a titlebar
  819. -- awful.titlebar.add(c, { modkey = modkey })
  820.  
  821. -- Enable sloppy focus
  822. c:add_signal("mouse::enter", function(c)
  823. if awful.layout.get(c.screen) ~= awful.layout.suit.magnifier
  824. and awful.client.focus.filter(c) then
  825. client.focus = c
  826. end
  827. end)
  828.  
  829. if not startup then
  830. -- Set the windows at the slave,
  831. -- i.e. put it at the end of others instead of setting it master.
  832. -- awful.client.setslave(c)
  833.  
  834. -- Put windows in a smart way, only if they does not set an initial position.
  835. if not c.size_hints.user_position and not c.size_hints.program_position then
  836. awful.placement.no_overlap(c)
  837. awful.placement.no_offscreen(c)
  838. end
  839. end
  840. end)
  841.  
  842. client.add_signal("focus", function(c) c.border_color = beautiful.border_focus end)
  843. client.add_signal("unfocus", function(c) c.border_color = beautiful.border_normal end)
  844. -- }}}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement