Advertisement
Guest User

Untitled

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