Advertisement
Guest User

Awesomewm KDE configuration

a guest
Oct 30th, 2010
822
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 13.79 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.  
  10. -- {{{ Variable definitions
  11. -- Themes define colours, icons, and wallpapers
  12. beautiful.init("/usr/share/awesome/themes/default/theme.lua")
  13.  
  14. -- This is used later as the default terminal and editor to run.
  15. terminal = "konsole"
  16. editor = os.getenv("EDITOR") or "vi"
  17. editor_cmd = terminal .. " -e " .. editor
  18. file_manager = "dolphin"
  19.  
  20. -- Default modkey.
  21. -- Usually, Mod4 is the key with a logo between Control and Alt.
  22. -- If you do not like this or do not have such a key,
  23. -- I suggest you to remap Mod4 to another key using xmodmap or other tools.
  24. -- However, you can use another modifier like Mod1, but it may interact with others.
  25. modkey = "Mod4"
  26.  
  27. -- Table of layouts to cover with awful.layout.inc, order matters.
  28. layouts =
  29. {
  30. awful.layout.suit.floating,
  31. awful.layout.suit.tile,
  32. awful.layout.suit.tile.left,
  33. awful.layout.suit.tile.bottom,
  34. awful.layout.suit.tile.top,
  35. awful.layout.suit.fair,
  36. awful.layout.suit.fair.horizontal,
  37. -- awful.layout.suit.spiral,
  38. -- awful.layout.suit.spiral.dwindle,
  39. awful.layout.suit.max,
  40. awful.layout.suit.max.fullscreen,
  41. awful.layout.suit.magnifier
  42. }
  43. -- }}}
  44.  
  45. -- {{{ Tags
  46. -- Define a tag table which hold all screen tags.
  47. tags = {
  48. names = { 0, "prog", "uni", "im" },
  49. layouts = { layouts[1], layouts[6], layouts[2], layouts[8] }
  50. }
  51.  
  52. for s = 1, screen.count() do
  53. -- Each screen has its own tag table.
  54. tags[s] = awful.tag(tags.names, s, tags.layouts)
  55. end
  56. -- }}}
  57.  
  58. -- {{{ Menu
  59. -- Create a laucher widget and a main menu
  60. myawesomemenu = {
  61. { "edit config", editor_cmd .. " " .. awful.util.getdir("config") .. "/rc.lua" },
  62. { "restart", awesome.restart },
  63. }
  64.  
  65. mymainmenu = awful.menu({ items = { { "awesome", myawesomemenu, beautiful.awesome_icon },
  66. { "open terminal", terminal }
  67. }
  68. })
  69.  
  70. mylauncher = awful.widget.launcher({ image = image(beautiful.awesome_icon),
  71. menu = mymainmenu })
  72. -- }}}
  73.  
  74. -- {{{ Wibox
  75. -- Create a textclock widget
  76. mytextclock = awful.widget.textclock({ align = "right" })
  77.  
  78. -- Create a wibox for each screen and add it
  79. mywibox = {}
  80. mypromptbox = {}
  81. mylayoutbox = {}
  82. mytaglist = {}
  83. mytaglist.buttons = awful.util.table.join(
  84. awful.button({ }, 1, awful.tag.viewonly),
  85. awful.button({ modkey }, 1, awful.client.movetotag),
  86. awful.button({ }, 3, awful.tag.viewtoggle),
  87. awful.button({ modkey }, 3, awful.client.toggletag),
  88. awful.button({ }, 4, awful.tag.viewprev),
  89. awful.button({ }, 5, awful.tag.viewnext)
  90. )
  91. mytasklist = {}
  92. mytasklist.buttons = awful.util.table.join(
  93. awful.button({ }, 1, function (c)
  94. if not c:isvisible() then
  95. awful.tag.viewonly(c:tags()[1])
  96. end
  97. client.focus = c
  98. c:raise()
  99. end),
  100. awful.button({ }, 3, function ()
  101. if instance then
  102. instance:hide()
  103. instance = nil
  104. else
  105. instance = awful.menu.clients({ width=250 })
  106. end
  107. end),
  108. awful.button({ }, 4, function ()
  109. awful.client.focus.byidx(-1)
  110. if client.focus then client.focus:raise() end
  111. end),
  112. awful.button({ }, 5, function ()
  113. awful.client.focus.byidx(1)
  114. if client.focus then client.focus:raise() end
  115. end))
  116.  
  117. for s = 1, screen.count() do
  118. -- Create a promptbox for each screen
  119. mypromptbox[s] = awful.widget.prompt({ layout = awful.widget.layout.horizontal.leftright })
  120. -- Create an imagebox widget which will contains an icon indicating which layout we're using.
  121. -- We need one layoutbox per screen.
  122. mylayoutbox[s] = awful.widget.layoutbox(s)
  123. mylayoutbox[s]:buttons(awful.util.table.join(
  124. awful.button({ }, 1, function () awful.layout.inc(layouts, 1) end),
  125. awful.button({ }, 3, function () awful.layout.inc(layouts, -1) end),
  126. awful.button({ }, 4, function () awful.layout.inc(layouts, 1) end),
  127. awful.button({ }, 5, function () awful.layout.inc(layouts, -1) end)))
  128. -- Create a taglist widget
  129. mytaglist[s] = awful.widget.taglist(s, awful.widget.taglist.label.all, mytaglist.buttons)
  130.  
  131. -- Create a tasklist widget
  132. mytasklist[s] = awful.widget.tasklist(function(c)
  133. return awful.widget.tasklist.label.currenttags(c, s)
  134. end, mytasklist.buttons)
  135.  
  136. -- Create the wibox
  137. mywibox[s] = awful.wibox({ position = "top", screen = s })
  138. -- Add widgets to the wibox - order matters
  139. mywibox[s].widgets = {
  140. {
  141. mylauncher,
  142. mytaglist[s],
  143. mypromptbox[s],
  144. layout = awful.widget.layout.horizontal.leftright
  145. },
  146. mylayoutbox[s],
  147. mytextclock,
  148. mytasklist[s],
  149. layout = awful.widget.layout.horizontal.rightleft
  150. }
  151. end
  152. -- }}}
  153.  
  154. -- {{{ Key bindings
  155. globalkeys = awful.util.table.join(
  156. awful.key({ modkey, }, "Left", awful.tag.viewprev ),
  157. awful.key({ modkey, }, "Right", awful.tag.viewnext ),
  158. -- awful.key({ modkey, }, "Escape", awful.tag.history.restore),
  159.  
  160. awful.key({ modkey, }, "/",
  161. function ()
  162. awful.client.focus.byidx( 1)
  163. if client.focus then client.focus:raise() end
  164. end),
  165.  
  166. -- Layout manipulation
  167. awful.key({ modkey, "Shift" }, "j", function () awful.client.swap.byidx( 1) end),
  168. awful.key({ modkey, "Shift" }, "k", function () awful.client.swap.byidx( -1) end),
  169. awful.key({ modkey, "Control" }, "/", function () awful.screen.focus_relative( 1) end),
  170. awful.key({ modkey, }, "u", awful.client.urgent.jumpto),
  171. awful.key({ modkey, }, "Tab",
  172. function ()
  173. awful.client.focus.history.previous()
  174. if client.focus then
  175. client.focus:raise()
  176. end
  177. end),
  178.  
  179. -- Standard program
  180. awful.key({ modkey, }, "Return", function () awful.util.spawn(terminal) end),
  181. awful.key({ modkey, "Shift" }, "Return", function () awful.util.spawn(file_manager) end),
  182. -- awful.key({ modkey, "Control" }, "r", awesome.restart),
  183. -- awful.key({ modkey, "Shift" }, "q", awesome.quit),
  184.  
  185. awful.key({ modkey, }, "l", function () awful.tag.incmwfact( 0.05) end),
  186. awful.key({ modkey, }, "h", function () awful.tag.incmwfact(-0.05) end),
  187. awful.key({ modkey, "Shift" }, "h", function () awful.tag.incnmaster( 1) end),
  188. awful.key({ modkey, "Shift" }, "l", function () awful.tag.incnmaster(-1) end),
  189. awful.key({ modkey, "Control" }, "h", function () awful.tag.incncol( 1) end),
  190. awful.key({ modkey, "Control" }, "l", function () awful.tag.incncol(-1) end),
  191. awful.key({ modkey, }, "space", function () awful.layout.inc(layouts, 1) end),
  192. awful.key({ modkey, "Shift" }, "space", function () awful.layout.inc(layouts, -1) end),
  193.  
  194. -- Prompt
  195. awful.key({ modkey }, "r", function () mypromptbox[mouse.screen]:run() end)
  196.  
  197. )
  198.  
  199. clientkeys = awful.util.table.join(
  200. awful.key({ modkey, }, "f", function (c) c.fullscreen = not c.fullscreen end),
  201. awful.key({ modkey, }, "Escape", function (c) c:kill() end),
  202. awful.key({ modkey, "Control" }, "space", awful.client.floating.toggle ),
  203. awful.key({ modkey, "Control" }, "Return", function (c) c:swap(awful.client.getmaster()) end),
  204. awful.key({ modkey, }, "o", awful.client.movetoscreen ),
  205. awful.key({ modkey, "Shift" }, "r", function (c) c:redraw() end),
  206. awful.key({ modkey, }, "t", function (c) c.ontop = not c.ontop end),
  207. awful.key({ modkey, }, "n", function (c) c.minimized = not c.minimized end),
  208. awful.key({ modkey, }, "m",
  209. function (c)
  210. c.maximized_horizontal = not c.maximized_horizontal
  211. c.maximized_vertical = not c.maximized_vertical
  212. end)
  213. )
  214.  
  215. -- Compute the maximum number of digit we need, limited to 9
  216. keynumber = 0
  217. for s = 1, screen.count() do
  218. keynumber = math.min(9, math.max(#tags[s], keynumber));
  219. end
  220.  
  221. -- Bind all key numbers to tags.
  222. -- Be careful: we use keycodes to make it works on any keyboard layout.
  223. -- This should map on the top row of your keyboard, usually 1 to 9.
  224. for i = 1, keynumber do
  225. globalkeys = awful.util.table.join(globalkeys,
  226. awful.key({ modkey }, "#" .. i + 9,
  227. function ()
  228. local screen = mouse.screen
  229. if tags[screen][i] then
  230. awful.tag.viewonly(tags[screen][i])
  231. end
  232. end),
  233. awful.key({ modkey, "Control" }, "#" .. i + 9,
  234. function ()
  235. local screen = mouse.screen
  236. if tags[screen][i] then
  237. awful.tag.viewtoggle(tags[screen][i])
  238. end
  239. end),
  240. awful.key({ modkey, "Shift" }, "#" .. i + 9,
  241. function ()
  242. if client.focus and tags[client.focus.screen][i] then
  243. awful.client.movetotag(tags[client.focus.screen][i])
  244. end
  245. end),
  246. awful.key({ modkey, "Control", "Shift" }, "#" .. i + 9,
  247. function ()
  248. if client.focus and tags[client.focus.screen][i] then
  249. awful.client.toggletag(tags[client.focus.screen][i])
  250. end
  251. end))
  252. end
  253.  
  254. clientbuttons = awful.util.table.join(
  255. awful.button({ }, 1, function (c) client.focus = c; c:raise() end),
  256. awful.button({ }, 4, function (c) client.focus = c end),
  257. awful.button({ }, 5, function (c) client.focus = c end),
  258. awful.button({ modkey }, 1, awful.mouse.client.move),
  259. awful.button({ modkey }, 3, awful.mouse.client.resize))
  260.  
  261. -- Set keys
  262. root.keys(globalkeys)
  263. -- }}}
  264.  
  265. -- {{{ Rules
  266. awful.rules.rules = {
  267. -- All clients will match this rule.
  268. { rule = { },
  269. properties = { border_width = beautiful.border_width,
  270. border_color = beautiful.border_normal,
  271. focus = true,
  272. keys = clientkeys,
  273. maximized_vertical = false,
  274. maximized_horizontal = false,
  275. buttons = clientbuttons } },
  276. -- Start clients as slaves
  277. -- callback = awful.client.setslave },
  278. { rule = { class = "MPlayer" },
  279. properties = { floating = true } },
  280. { rule = { class = "krunner" },
  281. properties = { border_width = 0 } },
  282. -- { rule = { class = "pinentry" },
  283. -- properties = { floating = true } },
  284. -- { rule = { class = "gimp" },
  285. -- properties = { floating = true } },
  286. { rule = { class = "dashboard" },
  287. properties = { floating = true } },
  288. { rule = { class = "Cairo-clock" },
  289. properties = { floating = true } },
  290. { rule = { class = "Ktorrent" },
  291. properties = { floating = true } },
  292. { rule = { class = "psi", instance = "main" },
  293. properties = { floating = true } },
  294. { rule = { class = "psi", instance = "chat" },
  295. properties = { floating = false } },
  296. }
  297. -- }}}
  298.  
  299. -- {{{ Signals
  300. -- Signal function to execute when a new client appears.
  301. client.add_signal("manage", function (c, startup)
  302. -- Add a titlebar
  303. -- awful.titlebar.add(c, { modkey = modkey })
  304.  
  305. -- Enable sloppy focus
  306. c:add_signal("mouse::enter", function(c)
  307. if awful.layout.get(c.screen) ~= awful.layout.suit.magnifier
  308. and awful.client.focus.filter(c) then
  309. client.focus = c
  310. end
  311. end)
  312.  
  313. if not startup then
  314. -- Set the windows at the slave,
  315. -- i.e. put it at the end of others instead of setting it master.
  316. -- awful.client.setslave(c)
  317.  
  318. -- Put windows in a smart way, only if they does not set an initial position.
  319. if not c.size_hints.user_position and not c.size_hints.program_position then
  320. awful.placement.no_overlap(c)
  321. awful.placement.no_offscreen(c)
  322. end
  323. end
  324. end)
  325.  
  326. client.add_signal("focus", function(c) c.border_color = beautiful.border_focus end)
  327. client.add_signal("unfocus", function(c) c.border_color = beautiful.border_normal end)
  328. -- }}}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement