Advertisement
Guest User

Untitled

a guest
Mar 17th, 2013
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 20.41 KB | None | 0 0
  1. -- Standard awesome library
  2. require("awful")
  3. require("awful.autofocus")
  4. require("awful.rules")
  5. -- Theme handling library
  6. require("beautiful")
  7. -- Notification library
  8. require("naughty")
  9. -- Load Debian menu entries
  10. require("debian.menu")
  11. -- User libraries
  12. vicious = require("vicious")
  13. -- scratch = require("scratch")
  14. --{{ Java GUI's fix
  15. awful.util.spawn_with_shell("wmname LG3D")
  16.  
  17.  
  18. --Autostart
  19. function run_once(prg, args)
  20. if not prg then
  21. do return nil end
  22. end
  23. if not args then
  24. args=""
  25. end
  26. awful.util.spawn_with_shell('pgrep -f -u $USER -x ' .. prg .. ' || (' .. prg .. ' ' .. args .. ')')
  27. end
  28.  
  29. -- {{{ Error handling
  30. -- Check if awesome encountered an error during startup and fell back to
  31. -- another config (This code will only ever execute for the fallback config)
  32. if awesome.startup_errors then
  33. naughty.notify({ preset = naughty.config.presets.critical,
  34. title = "Oops, there were errors during startup!",
  35. text = awesome.startup_errors })
  36. end
  37.  
  38. -- Handle runtime errors after startup
  39. do
  40. local in_error = false
  41. awesome.add_signal("debug::error", function (err)
  42. -- Make sure we don't go into an endless error loop
  43. if in_error then return end
  44. in_error = true
  45.  
  46. naughty.notify({ preset = naughty.config.presets.critical,
  47. title = "Oops, an error happened!",
  48. text = err })
  49. in_error = false
  50. end)
  51. end
  52. -- }}}
  53.  
  54. -- {{{ Variable definitions
  55. -- Themes define colours, icons, and wallpapers
  56. -- beautiful.init("/usr/share/awesome/themes/default/theme.lua")
  57. config_dir=("/home/murat/.config/awesome/")
  58. beautiful.init(config_dir .. "zenburn.lua")
  59.  
  60. -- This is used later as the default terminal and editor to run.
  61. terminal = "gnome-terminal"
  62. editor = os.getenv("EDITOR") or "nano"
  63. editor_cmd = terminal .. " -e " .. editor
  64.  
  65. -- Default modkey.
  66. -- Usually, Mod4 is the key with a logo between Control and Alt.
  67. -- If you do not like this or do not have such a key,
  68. -- I suggest you to remap Mod4 to another key using xmodmap or other tools.
  69. -- However, you can use another modifier like Mod1, but it may interact with others.
  70. modkey = "Mod4"
  71.  
  72. run_once("nm-applet")
  73. run_once("jupiter")
  74. run_once("xxkb")
  75. run_once("skype")
  76. run_once("pkexec /usr/lib/gnome-settings-daemon/gsd-backlight-helper --set-brightness 2 ")
  77. run_once("dbus-send --type=method_call --system --dest=org.freedesktop.UPower /org/freedesktop/UPower/KbdBacklight org.freedesktop.UPower.KbdBacklight.SetBrightness int32:0")
  78. -- Table of layouts to cover with awful.layout.inc, order matters.
  79. layouts =
  80. {
  81. awful.layout.suit.floating, --1
  82. awful.layout.suit.tile, --2
  83. awful.layout.suit.tile.left,--3
  84. awful.layout.suit.tile.bottom,--4
  85. awful.layout.suit.tile.top, --5
  86. --awful.layout.suit.fair,
  87. --awful.layout.suit.fair.horizontal,
  88. --awful.layout.suit.spiral,
  89. --awful.layout.suit.spiral.dwindle,
  90. --awful.layout.suit.max,
  91. --awful.layout.suit.max.fullscreen,
  92. --awful.layout.suit.magnifier
  93. }
  94. -- }}}
  95.  
  96. -- {{{ Tags
  97. -- Define a tag table which will hold all screen tags.
  98. tags = {
  99. names = { "www", "dev", "im", "misc", "film" },
  100. layout = { layouts[2], layouts[2], layouts[1], layouts[5], layouts[5],
  101. }}
  102. for s = 1, screen.count() do
  103. -- Each screen has its own tag table.
  104. tags[s] = awful.tag(tags.names, s, tags.layout)
  105. end
  106. -- }}}
  107.  
  108. -- {{{ Menu
  109. -- Create a laucher widget and a main menu
  110. myawesomemenu = {
  111. { "manual", terminal .. " -e man awesome" },
  112. { "edit config", editor_cmd .. " " .. awesome.conffile },
  113. { "restart", awesome.restart },
  114. { "quit", awesome.quit }
  115. }
  116.  
  117. mymainmenu = awful.menu({ items = { { "Awesome", myawesomemenu, beautiful.awesome_icon },
  118. { "Terminal", terminal },
  119. {"Chrome", "google-chrome"},
  120. {"Sublime", "sublime-text-2"},
  121. {"Nautilus", "nautilus --no-desktop"},
  122. {"Transsmision", "transsmision-gtk"},
  123. {"Skype", "skype"},
  124. {"Vlc", "vlc"},
  125. {"Suspend", "dbus-send --system --print-reply --dest=\"org.freedesktop.UPower\" /org/freedesktop/UPower org.freedesktop.UPower.Suspend"},
  126. {"Reboot", "dbus-send --system --print-reply --dest=\"org.freedesktop.ConsoleKit\" /org/freedesktop/ConsoleKit/Manager org.freedesktop.ConsoleKit.Manager.Restart"},
  127. {"Shutdown", "dbus-send --system --print-reply --dest=\"org.freedesktop.ConsoleKit\" /org/freedesktop/ConsoleKit/Manager org.freedesktop.ConsoleKit.Manager.Stop"}
  128. }
  129. })
  130.  
  131. mylauncher = awful.widget.launcher({ image = image(beautiful.awesome_icon),
  132. menu = mymainmenu })
  133. -- }}}
  134.  
  135. -- {{{ Wibox
  136.  
  137. -- Create a textclock widget
  138. --mytextclock = awful.widget.textclock({ align = "right" })
  139.  
  140. datewidget = widget({ type = "textbox" })
  141. vicious.register(datewidget, vicious.widgets.date, "%d.%m %H:%M")
  142.  
  143. -- Create a systray
  144. mysystray = widget({ type = "systray" })
  145.  
  146. -- seperator
  147. seperator = widget({ type = "textbox" })
  148. seperator.text = " | "
  149.  
  150. -- {{{ Battery state
  151. baticon = widget({ type = "imagebox" })
  152. baticon.image = image(beautiful.widget_bat)
  153. batwidget = widget({ type = "textbox" })
  154. vicious.register(batwidget, vicious.widgets.bat, "$2%", 61, "BAT0")
  155. -- }}
  156.  
  157. -- Weather widget
  158. weatherwidget = widget({ type = "textbox" })
  159. weather_t = awful.tooltip({ objects = { weatherwidget },})
  160.  
  161. vicious.register(weatherwidget, vicious.widgets.weather,
  162. function (widget, args)
  163. weather_t:set_text("City: " .. args["{city}"] .."\nWind: " .. args["{windkmh}"] .. "km/h " .. args["{wind}"] .. "\nSky: " .. args["{sky}"] .. "\nHumidity: " .. args["{humid}"] .. "%")
  164. return args["{tempc}"] .. "°C"
  165. end, 1800, "LKKB")
  166. --'1800': check every 30 minutes.
  167. --'LKKB': the Prague ICAO code.
  168.  
  169.  
  170. --{{{ Create a volume widget
  171. volumewidget = widget({ type = "textbox"})
  172. vicious.register(volumewidget, vicious.widgets.volume,
  173. function(widget, args) return "♫:" .. args[1] .. "%" end, 2, "Master")
  174. --}}}
  175.  
  176. ---{{{
  177. mailicon = widget ({ type = "textbox" })
  178. mailicon.bg_image = image(beautiful.widget_mail)
  179. mailicon.bg_align = "middle"
  180. mailicon.width = 10
  181. mailinfo = widget ({ type = "textbox" })
  182. vicious.register(mailinfo, vicious.widgets.gmail,
  183. function (widget, args)
  184. if args["{count}"] == 0 then
  185. mailicon.bg_image = image(beautiful.widget_mail)
  186. return 0
  187. else
  188. mailicon.bg_image = image(beautiful.widget_mail)
  189. return args["{count}"]
  190. end
  191. end, 61)
  192. ---}}}
  193.  
  194.  
  195. -- Create a wibox for each screen and add it
  196. mywibox = {}
  197. mypromptbox = {}
  198. mylayoutbox = {}
  199. mytaglist = {}
  200. mytaglist.buttons = awful.util.table.join(
  201. awful.button({ }, 1, awful.tag.viewonly),
  202. awful.button({ modkey }, 1, awful.client.movetotag),
  203. awful.button({ }, 3, awful.tag.viewtoggle),
  204. awful.button({ modkey }, 3, awful.client.toggletag),
  205. awful.button({ }, 4, awful.tag.viewnext),
  206. awful.button({ }, 5, awful.tag.viewprev)
  207. )
  208. mytasklist = {}
  209. mytasklist.buttons = awful.util.table.join(
  210. awful.button({ }, 1, function (c)
  211. if c == client.focus then
  212. c.minimized = true
  213. else
  214. if not c:isvisible() then
  215. awful.tag.viewonly(c:tags()[1])
  216. end
  217. -- This will also un-minimize
  218. -- the client, if needed
  219. client.focus = c
  220. c:raise()
  221. end
  222. end),
  223. awful.button({ }, 3, function ()
  224. if instance then
  225. instance:hide()
  226. instance = nil
  227. else
  228. instance = awful.menu.clients({ width=250 })
  229. end
  230. end),
  231. awful.button({ }, 4, function ()
  232. awful.client.focus.byidx(1)
  233. if client.focus then client.focus:raise() end
  234. end),
  235. awful.button({ }, 5, function ()
  236. awful.client.focus.byidx(-1)
  237. if client.focus then client.focus:raise() end
  238. end))
  239.  
  240. for s = 1, screen.count() do
  241. -- Create a promptbox for each screen
  242. mypromptbox[s] = awful.widget.prompt({ layout = awful.widget.layout.horizontal.leftright })
  243. -- Create an imagebox widget which will contains an icon indicating which layout we're using.
  244. -- We need one layoutbox per screen.
  245. mylayoutbox[s] = awful.widget.layoutbox(s)
  246. mylayoutbox[s]:buttons(awful.util.table.join(
  247. awful.button({ }, 1, function () awful.layout.inc(layouts, 1) end),
  248. awful.button({ }, 3, function () awful.layout.inc(layouts, -1) end),
  249. awful.button({ }, 4, function () awful.layout.inc(layouts, 1) end),
  250. awful.button({ }, 5, function () awful.layout.inc(layouts, -1) end)))
  251. -- Create a taglist widget
  252. mytaglist[s] = awful.widget.taglist(s, awful.widget.taglist.label.all, mytaglist.buttons)
  253.  
  254. -- Create a tasklist widget
  255. mytasklist[s] = awful.widget.tasklist(function(c)
  256. return awful.widget.tasklist.label.currenttags(c, s)
  257. end, mytasklist.buttons)
  258.  
  259. -- Create the wibox
  260. mywibox[s] = awful.wibox({ position = "top", screen = s })
  261. -- Add widgets to the wibox - order matters
  262. mywibox[s].widgets = {
  263. {
  264. mylauncher,
  265. mytaglist[s],
  266. mypromptbox[s],
  267. mylayoutbox[s],
  268. layout = awful.widget.layout.horizontal.leftright
  269. },
  270. batwidget, seperator,
  271. datewidget, seperator,
  272. volumewidget, seperator,
  273. mailinfo,seperator,
  274. weatherwidget, seperator,
  275. s == 1 and mysystray or nil,
  276. mytasklist[s],
  277. layout = awful.widget.layout.horizontal.rightleft
  278. }
  279. end
  280. -- }}}
  281.  
  282. -- {{{ Mouse bindings
  283. root.buttons(awful.util.table.join(
  284. awful.button({ }, 3, function () mymainmenu:toggle() end),
  285. awful.button({ }, 4, awful.tag.viewnext),
  286. awful.button({ }, 5, awful.tag.viewprev
  287. )))
  288. -- }}}
  289.  
  290. ---{{{
  291. -- awful.key({ modkey }, "F11", function () scratch.drop("gmrun") end),
  292. ---}}}
  293.  
  294. -- {{{ Key bindings
  295. globalkeys = awful.util.table.join(
  296. awful.key({ modkey, }, "Left", awful.tag.viewprev ),
  297. awful.key({ modkey, }, "Right", awful.tag.viewnext ),
  298. awful.key({ modkey, }, "Escape", awful.tag.history.restore),
  299.  
  300. awful.key({ modkey, }, "j",
  301. function ()
  302. awful.client.focus.byidx( 1)
  303. if client.focus then client.focus:raise() end
  304. end),
  305. awful.key({ modkey, }, "k",
  306. function ()
  307. awful.client.focus.byidx(-1)
  308. if client.focus then client.focus:raise() end
  309. end),
  310. awful.key({ modkey, }, "w", function () mymainmenu:show({keygrabber=true}) end),
  311. awful.key({ }, "XF86AudioRaiseVolume", function () awful.util.spawn_with_shell("amixer -D pulse set Master 4%+ unmute") end),
  312. awful.key({ }, "XF86AudioLowerVolume", function () awful.util.spawn_with_shell("amixer -D pulse set Master 4%- unmute") end),
  313. awful.key({ }, "XF86AudioMute", function () awful.util.spawn_with_shell("amixer -D pulse set Master 1+ toggle") end),
  314. awful.key({ }, "XF86KbdBrightnessDown", function () awful.util.spawn_with_shell("dbus-send --type=method_call --system --dest=org.freedesktop.UPower /org/freedesktop/UPower/KbdBacklight org.freedesktop.UPower.KbdBacklight.SetBrightness int32:0") end),
  315. awful.key({ }, "XF86KbdBrightnessUp", function () awful.util.spawn_with_shell("dbus-send --type=method_call --system --dest=org.freedesktop.UPower /org/freedesktop/UPower/KbdBacklight org.freedesktop.UPower.KbdBacklight.SetBrightness int32:3") end),
  316.  
  317. -- Layout manipulation
  318. awful.key({ modkey, "Shift" }, "j", function () awful.client.swap.byidx( 1) end),
  319. awful.key({ modkey, "Shift" }, "k", function () awful.client.swap.byidx( -1) end),
  320. awful.key({ modkey, "Control" }, "j", function () awful.screen.focus_relative( 1) end),
  321. awful.key({ modkey, "Control" }, "k", function () awful.screen.focus_relative(-1) end),
  322. awful.key({ modkey, }, "u", awful.client.urgent.jumpto),
  323. awful.key({ modkey, }, "Tab",
  324. function ()
  325. awful.client.focus.history.previous()
  326. if client.focus then
  327. client.focus:raise()
  328. end
  329. end),
  330.  
  331. -- Standard program
  332. awful.key({ modkey, }, "Return", function () awful.util.spawn(terminal) end),
  333. awful.key({ modkey, "Control" }, "r", awesome.restart),
  334. awful.key({ modkey, "Shift" }, "q", awesome.quit),
  335.  
  336. awful.key({ modkey, }, "l", function () awful.tag.incmwfact( 0.05) end),
  337. awful.key({ modkey, }, "h", function () awful.tag.incmwfact(-0.05) end),
  338. awful.key({ modkey, "Shift" }, "h", function () awful.tag.incnmaster( 1) end),
  339. awful.key({ modkey, "Shift" }, "l", function () awful.tag.incnmaster(-1) end),
  340. awful.key({ modkey, "Control" }, "h", function () awful.tag.incncol( 1) end),
  341. awful.key({ modkey, "Control" }, "l", function () awful.tag.incncol(-1) end),
  342. awful.key({ modkey, }, "space", function () awful.layout.inc(layouts, 1) end),
  343. awful.key({ modkey, "Shift" }, "space", function () awful.layout.inc(layouts, -1) end),
  344.  
  345. awful.key({ modkey, "Control" }, "n", awful.client.restore),
  346.  
  347. -- Prompt
  348. awful.key({ modkey }, "r", function () mypromptbox[mouse.screen]:run() end),
  349.  
  350. awful.key({ modkey }, "x",
  351. function ()
  352. awful.prompt.run({ prompt = "Run Lua code: " },
  353. mypromptbox[mouse.screen].widget,
  354. awful.util.eval, nil,
  355. awful.util.getdir("cache") .. "/history_eval")
  356. end)
  357. )
  358.  
  359. clientkeys = awful.util.table.join(
  360. awful.key({ modkey, }, "f", function (c) c.fullscreen = not c.fullscreen end),
  361. awful.key({ modkey, }, "q", function (c) c:kill() end),
  362. awful.key({ modkey, "Control" }, "space", awful.client.floating.toggle ),
  363. awful.key({ modkey, "Control" }, "Return", function (c) c:swap(awful.client.getmaster()) end),
  364. awful.key({ modkey, }, "o", awful.client.movetoscreen ),
  365. awful.key({ modkey, "Shift" }, "r", function (c) c:redraw() end),
  366. awful.key({ modkey, }, "t", function (c) c.ontop = not c.ontop end),
  367. awful.key({ modkey, }, "n",
  368. function (c)
  369. -- The client currently has the input focus, so it cannot be
  370. -- minimized, since minimized clients can't have the focus.
  371. c.minimized = true
  372. end),
  373. awful.key({ modkey, }, "m",
  374. function (c)
  375. c.maximized_horizontal = not c.maximized_horizontal
  376. c.maximized_vertical = not c.maximized_vertical
  377. end)
  378. )
  379.  
  380. -- Compute the maximum number of digit we need, limited to 9
  381. keynumber = 0
  382. for s = 1, screen.count() do
  383. keynumber = math.min(9, math.max(#tags[s], keynumber));
  384. end
  385.  
  386. -- Bind all key numbers to tags.
  387. -- Be careful: we use keycodes to make it works on any keyboard layout.
  388. -- This should map on the top row of your keyboard, usually 1 to 9.
  389. for i = 1, keynumber do
  390. globalkeys = awful.util.table.join(globalkeys,
  391. awful.key({ modkey }, "#" .. i + 9,
  392. function ()
  393. local screen = mouse.screen
  394. if tags[screen][i] then
  395. awful.tag.viewonly(tags[screen][i])
  396. end
  397. end),
  398. awful.key({ modkey, "Control" }, "#" .. i + 9,
  399. function ()
  400. local screen = mouse.screen
  401. if tags[screen][i] then
  402. awful.tag.viewtoggle(tags[screen][i])
  403. end
  404. end),
  405. awful.key({ modkey, "Shift" }, "#" .. i + 9,
  406. function ()
  407. if client.focus and tags[client.focus.screen][i] then
  408. awful.client.movetotag(tags[client.focus.screen][i])
  409. end
  410. end),
  411. awful.key({ modkey, "Control", "Shift" }, "#" .. i + 9,
  412. function ()
  413. if client.focus and tags[client.focus.screen][i] then
  414. awful.client.toggletag(tags[client.focus.screen][i])
  415. end
  416. end))
  417. end
  418.  
  419. clientbuttons = awful.util.table.join(
  420. awful.button({ }, 1, function (c) client.focus = c; c:raise() end),
  421. awful.button({ modkey }, 1, awful.mouse.client.move),
  422. awful.button({ modkey }, 3, awful.mouse.client.resize))
  423.  
  424. -- Set keys
  425. root.keys(globalkeys)
  426. -- }}}
  427.  
  428. -- {{{ Rules
  429. awful.rules.rules = {
  430. -- All clients will match this rule.
  431. { rule = { },
  432. properties = { border_width = beautiful.border_width,
  433. border_color = beautiful.border_normal,
  434. focus = true,
  435. keys = clientkeys,
  436. buttons = clientbuttons } },
  437. { rule = { class = "MPlayer" },
  438. properties = { floating = true } },
  439. { rule = { class = "pinentry" },
  440. properties = { floating = true } },
  441. { rule = { class = "gimp" },
  442. properties = { floating = true } },
  443. -- Set Firefox to always map on tags number 2 of screen 1.
  444. { rule = { class = "Google-chrome" },
  445. properties = { tag = tags[1][1] } },
  446. { rule = { class = "Skype" },
  447. properties = { tag = tags[1][3] } },
  448. { rule = { class = "sublime-text-2" },
  449. properties = { tag = tags[1][2] } },
  450. { rule = { class = "Vlc" },
  451. properties = { tag = tags[1][5] } },
  452. -- { rule = { class = "Google-chrome" },
  453. -- properties = { tag = tags[1][1] } },
  454. }
  455. -- }}}
  456.  
  457. -- {{{ Signals
  458. -- Signal function to execute when a new client appears.
  459. client.add_signal("manage", function (c, startup)
  460. -- Add a titlebar
  461. -- awful.titlebar.add(c, { modkey = modkey })
  462.  
  463. -- Enable sloppy focus
  464. c:add_signal("mouse::enter", function(c)
  465. if awful.layout.get(c.screen) ~= awful.layout.suit.magnifier
  466. and awful.client.focus.filter(c) then
  467. client.focus = c
  468. end
  469. end)
  470.  
  471. if not startup then
  472. -- Set the windows at the slave,
  473. -- i.e. put it at the end of others instead of setting it master.
  474. -- awful.client.setslave(c)
  475.  
  476. -- Put windows in a smart way, only if they does not set an initial position.
  477. if not c.size_hints.user_position and not c.size_hints.program_position then
  478. awful.placement.no_overlap(c)
  479. awful.placement.no_offscreen(c)
  480. end
  481. end
  482. end)
  483.  
  484. client.add_signal("focus", function(c) c.border_color = beautiful.border_focus end)
  485. client.add_signal("unfocus", function(c) c.border_color = beautiful.border_normal end)
  486. -- }}}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement