Advertisement
Guest User

rc.lua tag problem

a guest
Jan 22nd, 2013
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 20.44 KB | None | 0 0
  1. -- Standard awesome library
  2. local gears = require("gears")
  3. local awful = require("awful")
  4. awful.rules = require("awful.rules")
  5. require("awful.autofocus")
  6. -- Widget and layout library
  7. local wibox = require("wibox")
  8. -- Theme handling library
  9. local beautiful = require("beautiful")
  10. -- Notification library
  11. local naughty = require("naughty")
  12. local menubar = require("menubar")
  13.  
  14.  
  15. local vicious = require("vicious")
  16. -- local delightful = require("delightful")
  17.  
  18. -- {{{ Error handling
  19. -- Check if awesome encountered an error during startup and fell back to
  20. -- another config (This code will only ever execute for the fallback config)
  21. if awesome.startup_errors then
  22.     naughty.notify({ preset = naughty.config.presets.critical,
  23.                      title = "FUCK! There were errors during startup!",
  24.                      text = awesome.startup_errors })
  25. end
  26.  
  27. -- Handle runtime errors after startup
  28. do
  29.     local in_error = false
  30.     awesome.connect_signal("debug::error", function (err)
  31.         -- Make sure we don't go into an endless error loop
  32.         if in_error then return end
  33.         in_error = true
  34.  
  35.         naughty.notify({ preset = naughty.config.presets.critical,
  36.                          title = "Oops, an error happened!",
  37.                          text = err })
  38.         in_error = false
  39.     end)
  40. end
  41. -- }}}
  42.  
  43. -- {{{ Variable definitions
  44. -- Themes define colours, icons, and wallpapers
  45. beautiful.init("/home/isaac/.config/awesome/themes/zenburn/theme.lua")
  46.  
  47. -- This is used later as the default terminal and editor to run.
  48. terminal = "xfce4-terminal"
  49. editor = "emacs"
  50. editor_cmd = terminal .. " -e " .. editor
  51.  
  52. -- Default modkey.
  53. -- Usually, Mod4 is the key with a logo between Control and Alt.
  54. -- If you do not like this or do not have such a key,
  55. -- I suggest you to remap Mod4 to another key using xmodmap or other tools.
  56. -- However, you can use another modifier like Mod1, but it may interact with others.
  57. modkey = "Mod4"
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73.  
  74.  
  75.  
  76. -- Table of layouts to cover with awful.layout.inc, order matters.
  77. local layouts =
  78. {
  79.    
  80.     awful.layout.suit.tile,
  81.     awful.layout.suit.tile.left,
  82.     awful.layout.suit.tile.bottom,
  83.     awful.layout.suit.tile.top,
  84.     awful.layout.suit.fair,
  85.     awful.layout.suit.fair.horizontal,
  86.     awful.layout.suit.spiral,
  87.     awful.layout.suit.spiral.dwindle,
  88.     awful.layout.suit.max,
  89.     awful.layout.suit.max.fullscreen,
  90.     awful.layout.suit.floating,
  91.     awful.layout.suit.magnifier
  92. }
  93. -- }}}
  94.  
  95. -- {{{ Wallpaper
  96. if beautiful.wallpaper then
  97.     for s = 1, screen.count() do
  98.         gears.wallpaper.maximized(beautiful.wallpaper, s, true)
  99.     end
  100. end
  101. -- }}}
  102.  
  103. -- {{{ Tags
  104. -- Define a tag table which hold all screen tags.
  105. tags = {}
  106. for s = 1, screen.count() do
  107.     -- Each screen has its own tag table.
  108.     tags[s] = awful.tag({ "一", "二", "三", "四", "五", "六", "七", "八", "九"}, s, layouts[1])
  109. --    tags[s] = awful.tag({ 1, 2, 3, 4, 5, 6, 7, 8, 9 }, s, layouts[1])
  110.  
  111.  
  112. end
  113. -- }}}
  114.  
  115. -- {{{ Menu
  116. -- Create a laucher widget and a main menu
  117. myawesomemenu = {
  118.    { "manual", terminal .. " -e man awesome" },
  119.    { "edit config", editor_cmd .. " " .. awesome.conffile },
  120.    { "restart", awesome.restart },
  121.    { "quit", awesome.quit }
  122. }
  123.  
  124. mymainmenu = awful.menu({ items = { { "awesome", myawesomemenu, beautiful.awesome_icon },
  125.                                     { "open terminal", terminal }, { "unmount external", "udiskie-umount --all"}
  126.                                   }
  127.                         })
  128.  
  129. mylauncher = awful.widget.launcher({ image = beautiful.awesome_icon,
  130.                                      menu = mymainmenu })
  131.  
  132. -- Menubar configuration
  133. menubar.utils.terminal = terminal -- Set the terminal for applications that require it
  134. -- }}}
  135.  
  136. -- {{{ Wibox
  137. -- Create a textclock widget
  138. mytextclock = awful.widget.textclock()
  139.  
  140.  
  141.  
  142. --vicious stuff
  143.  
  144. -- Initialize memwidget
  145. memwidget = awful.widget.progressbar()
  146. -- Progressbar properties
  147. memwidget:set_width(8)
  148. memwidget:set_height(8)
  149. memwidget:set_vertical(true)
  150. memwidget:set_background_color("#494B4F")
  151. memwidget:set_border_color(nil)
  152. memwidget:set_color("#FF5656")
  153. memwidget:set_color("linear:0,0:8,14:0,#FF5656:0.5,#88A175:1,#AECF96")
  154. -- Register widget
  155. vicious.register(memwidget, vicious.widgets.mem, "$1", 13)
  156.  
  157.  
  158. -- Initialize cpugraphwidget
  159. cpuwidget = awful.widget.graph()
  160. -- Graph properties
  161. cpuwidget:set_width(35)
  162. cpuwidget:set_height(8)
  163. cpuwidget:set_background_color("#494B4F")
  164. cpuwidget:set_color("#FF5656")
  165. cpuwidget:set_color("linear:0,0:8,14:0,#FF5656:0.5,#88A175:1,#AECF96")
  166. -- Register widget
  167. vicious.register(cpuwidget, vicious.widgets.cpu, "$1")
  168.  
  169.  
  170. -- initalize batwidget0
  171.   batwidget0 = awful.widget.progressbar()
  172.   batwidget0:set_width(8)
  173.   batwidget0:set_height(9)
  174.   batwidget0:set_vertical(true)
  175.   batwidget0:set_background_color("#494B4F")
  176.   batwidget0:set_border_color(nil)
  177.   batwidget0:set_color("#AECF96")
  178.   batwidget0:set_color("linear:0,0:8,14:0,#AECF96:0.5,#88A175:1,#FF5656")
  179.   vicious.register(batwidget0, vicious.widgets.bat, "$2", 61, "BAT0")
  180.  
  181. -- initalize batwidget1
  182.   batwidget1 = awful.widget.progressbar()
  183.   batwidget1:set_width(8)
  184.   batwidget1:set_height(9)
  185.   batwidget1:set_vertical(true)
  186.   batwidget1:set_background_color("#494B4F")
  187.   batwidget1:set_border_color(nil)
  188.   batwidget1:set_color("#AECF96")
  189.   batwidget1:set_color("linear:0,0:8,14:0,#AECF96:0.5,#88A175:1,#FF5656")
  190.   vicious.register(batwidget1, vicious.widgets.bat, "$2", 61, "BAT1")
  191.  
  192.  
  193.  
  194. --end vicious stuff
  195.  
  196.  
  197. spacerwidget = wibox.widget.textbox()
  198. spacerwidget:set_text(" 𐤇 ")
  199.  
  200.  
  201. smspacerwidget = wibox.widget.textbox()
  202. smspacerwidget:set_text("|")
  203.  
  204.  
  205.  
  206.  
  207.  
  208. -- Create a wibox for each screen and add it
  209. mywibox = {}
  210. mypromptbox = {}
  211. mylayoutbox = {}
  212. mytaglist = {}
  213. mytaglist.buttons = awful.util.table.join(
  214.                     awful.button({ }, 1, awful.tag.viewonly),
  215.                     awful.button({ modkey }, 1, awful.client.movetotag),
  216.                     awful.button({ }, 3, awful.tag.viewtoggle),
  217.                     awful.button({ modkey }, 3, awful.client.toggletag),
  218.                     awful.button({ }, 4, function(t) awful.tag.viewnext(awful.tag.getscreen(t)) end),
  219.                     awful.button({ }, 5, function(t) awful.tag.viewprev(awful.tag.getscreen(t)) end)
  220.                     )
  221. mytasklist = {}
  222. mytasklist.buttons = awful.util.table.join(
  223.                      awful.button({ }, 1, function (c)
  224.                                               if c == client.focus then
  225.                                                   c.minimized = true
  226.                                               else
  227.                                                   -- Without this, the following
  228.                                                   -- :isvisible() makes no sense
  229.                                                   c.minimized = false
  230.                                                   if not c:isvisible() then
  231.                                                       awful.tag.viewonly(c:tags()[1])
  232.                                                   end
  233.                                                   -- This will also un-minimize
  234.                                                   -- the client, if needed
  235.                                                   client.focus = c
  236.                                                   c:raise()
  237.                                               end
  238.                                           end),
  239.                      awful.button({ }, 3, function ()
  240.                                               if instance then
  241.                                                   instance:hide()
  242.                                                   instance = nil
  243.                                               else
  244.                                                   instance = awful.menu.clients({ width=250 })
  245.                                               end
  246.                                           end),
  247.                      awful.button({ }, 4, function ()
  248.                                               awful.client.focus.byidx(1)
  249.                                               if client.focus then client.focus:raise() end
  250.                                           end),
  251.                      awful.button({ }, 5, function ()
  252.                                               awful.client.focus.byidx(-1)
  253.                                               if client.focus then client.focus:raise() end
  254.                                           end))
  255.  
  256. for s = 1, screen.count() do
  257.     -- Create a promptbox for each screen
  258.     mypromptbox[s] = awful.widget.prompt()
  259.     -- Create an imagebox widget which will contains an icon indicating which layout we're using.
  260.     -- We need one layoutbox per screen.
  261.     mylayoutbox[s] = awful.widget.layoutbox(s)
  262.     mylayoutbox[s]:buttons(awful.util.table.join(
  263.                            awful.button({ }, 1, function () awful.layout.inc(layouts, 1) end),
  264.                            awful.button({ }, 3, function () awful.layout.inc(layouts, -1) end),
  265.                            awful.button({ }, 4, function () awful.layout.inc(layouts, 1) end),
  266.                            awful.button({ }, 5, function () awful.layout.inc(layouts, -1) end)))
  267.     -- Create a taglist widget
  268.     mytaglist[s] = awful.widget.taglist(s, awful.widget.taglist.filter.all, mytaglist.buttons)
  269.  
  270.     -- Create a tasklist widget
  271.     mytasklist[s] = awful.widget.tasklist(s, awful.widget.tasklist.filter.currenttags, mytasklist.buttons)
  272.  
  273.     -- Create the wibox
  274.     mywibox[s] = awful.wibox({ position = "top", screen = s })
  275.  
  276.     -- Widgets that are aligned to the left
  277.     local left_layout = wibox.layout.fixed.horizontal()
  278.     left_layout:add(mylauncher)
  279.     left_layout:add(mytaglist[s])
  280.     left_layout:add(mypromptbox[s])
  281.  
  282.     -- Widgets that are aligned to the right
  283.     local right_layout = wibox.layout.fixed.horizontal()
  284.     if s == 1 then right_layout:add(wibox.widget.systray()) end
  285.    
  286.  
  287.     right_layout:add(spacerwidget)
  288.     right_layout:add(cpuwidget)
  289.     right_layout:add(smspacerwidget)
  290.     right_layout:add(memwidget)
  291.     right_layout:add(spacerwidget)
  292.     right_layout:add(mytextclock)
  293.     right_layout:add(smspacerwidget)
  294.  
  295.     right_layout:add(batwidget0)
  296.     right_layout:add(smspacerwidget)
  297.     right_layout:add(batwidget1)
  298.     right_layout:add(smspacerwidget)
  299.  
  300.     right_layout:add(mylayoutbox[s])
  301.  
  302.  
  303.     -- Now bring it all together (with the tasklist in the middle)
  304.     local layout = wibox.layout.align.horizontal()
  305.     layout:set_left(left_layout)
  306.     layout:set_middle(mytasklist[s])
  307.     layout:set_right(right_layout)
  308.  
  309.     mywibox[s]:set_widget(layout)
  310. end
  311. -- }}}
  312.  
  313. -- {{{ Mouse bindings
  314. root.buttons(awful.util.table.join(
  315.     awful.button({ }, 3, function () mymainmenu:toggle() end)
  316. --    awful.button({ }, 4, awful.tag.viewnext),
  317. --    awful.button({ }, 5, awful.tag.viewprev)
  318. ))
  319. -- }}}
  320.  
  321. -- {{{ Key bindings
  322. globalkeys = awful.util.table.join(
  323.     awful.key({ modkey }, "F12", function () awful.util.spawn("xscreensaver-command --lock") end),
  324.     awful.key({ modkey,           }, "Left",   awful.tag.viewprev       ),
  325.     awful.key({ modkey,           }, "Right",  awful.tag.viewnext       ),
  326.     awful.key({ modkey,           }, "Escape", awful.tag.history.restore),
  327.  
  328.     awful.key({ modkey,           }, "j",
  329.         function ()
  330.             awful.client.focus.byidx( 1)
  331.             if client.focus then client.focus:raise() end
  332.         end),
  333.     awful.key({ modkey,           }, "k",
  334.         function ()
  335.             awful.client.focus.byidx(-1)
  336.             if client.focus then client.focus:raise() end
  337.         end),
  338.     awful.key({ modkey,           }, "w", function () mymainmenu:show() end),
  339.  
  340.     -- Layout manipulation
  341.     awful.key({ modkey, "Shift"   }, "j", function () awful.client.swap.byidx(  1)    end),
  342.     awful.key({ modkey, "Shift"   }, "k", function () awful.client.swap.byidx( -1)    end),
  343.     awful.key({ modkey, "Control" }, "j", function () awful.screen.focus_relative( 1) end),
  344.     awful.key({ modkey, "Control" }, "k", function () awful.screen.focus_relative(-1) end),
  345.     awful.key({ modkey,           }, "u", awful.client.urgent.jumpto),
  346.     awful.key({ modkey,           }, "Tab",
  347.         function ()
  348.             awful.client.focus.history.previous()
  349.             if client.focus then
  350.                 client.focus:raise()
  351.             end
  352.         end),
  353.  
  354.     -- Standard program
  355.     awful.key({ modkey,           }, "Return", function () awful.util.spawn(terminal) end),
  356.     awful.key({ modkey, "Control" }, "r", awesome.restart),
  357.     awful.key({ modkey, "Shift"   }, "q", awesome.quit),
  358.  
  359.     awful.key({ modkey,           }, "l",     function () awful.tag.incmwfact( 0.05)    end),
  360.     awful.key({ modkey,           }, "h",     function () awful.tag.incmwfact(-0.05)    end),
  361.     awful.key({ modkey, "Shift"   }, "h",     function () awful.tag.incnmaster( 1)      end),
  362.     awful.key({ modkey, "Shift"   }, "l",     function () awful.tag.incnmaster(-1)      end),
  363.     awful.key({ modkey, "Control" }, "h",     function () awful.tag.incncol( 1)         end),
  364.     awful.key({ modkey, "Control" }, "l",     function () awful.tag.incncol(-1)         end),
  365.     awful.key({ modkey,           }, "space", function () awful.layout.inc(layouts,  1) end),
  366.     awful.key({ modkey, "Shift"   }, "space", function () awful.layout.inc(layouts, -1) end),
  367.  
  368.     awful.key({ modkey, "Control" }, "n", awful.client.restore),
  369.  
  370.     -- Prompt
  371.     awful.key({ modkey },            "r",     function () mypromptbox[mouse.screen]:run() end),
  372.  
  373.     awful.key({ modkey }, "x",
  374.               function ()
  375.                   awful.prompt.run({ prompt = "Run Lua code: " },
  376.                   mypromptbox[mouse.screen].widget,
  377.                   awful.util.eval, nil,
  378.                   awful.util.getdir("cache") .. "/history_eval")
  379.               end),
  380.     -- Menubar
  381.     awful.key({ modkey }, "p", function() menubar.show() end)
  382. )
  383.  
  384. clientkeys = awful.util.table.join(
  385.     awful.key({ modkey,           }, "f",      function (c) c.fullscreen = not c.fullscreen  end),
  386.     awful.key({ modkey, "Shift"   }, "c",      function (c) c:kill()                         end),
  387.     awful.key({ modkey, "Control" }, "space",  awful.client.floating.toggle                     ),
  388.     awful.key({ modkey, "Control" }, "Return", function (c) c:swap(awful.client.getmaster()) end),
  389.     awful.key({ modkey,           }, "o",      awful.client.movetoscreen                        ),
  390.     awful.key({ modkey,           }, "t",      function (c) c.ontop = not c.ontop            end),
  391.     awful.key({ modkey,           }, "n",
  392.         function (c)
  393.             -- The client currently has the input focus, so it cannot be
  394.             -- minimized, since minimized clients can't have the focus.
  395.             c.minimized = true
  396.         end),
  397.     awful.key({ modkey,           }, "m",
  398.         function (c)
  399.             c.maximized_horizontal = not c.maximized_horizontal
  400.             c.maximized_vertical   = not c.maximized_vertical
  401.         end)
  402. )
  403.  
  404. -- Compute the maximum number of digit we need, limited to 9
  405. keynumber = 0
  406. for s = 1, screen.count() do
  407.    keynumber = math.min(9, math.max(#tags[s], keynumber))
  408. end
  409.  
  410. -- Bind all key numbers to tags.
  411. -- Be careful: we use keycodes to make it works on any keyboard layout.
  412. -- This should map on the top row of your keyboard, usually 1 to 9.
  413. for i = 1, keynumber do
  414.     globalkeys = awful.util.table.join(globalkeys,
  415.         awful.key({ modkey }, "#" .. i + 9,
  416.                   function ()
  417.                         local screen = mouse.screen
  418.                         if tags[screen][i] then
  419.                             awful.tag.viewonly(tags[screen][i])
  420.                         end
  421.                   end),
  422.         awful.key({ modkey, "Control" }, "#" .. i + 9,
  423.                   function ()
  424.                       local screen = mouse.screen
  425.                       if tags[screen][i] then
  426.                           awful.tag.viewtoggle(tags[screen][i])
  427.                       end
  428.                   end),
  429.         awful.key({ modkey, "Shift" }, "#" .. i + 9,
  430.                   function ()
  431.                       if client.focus and tags[client.focus.screen][i] then
  432.                           awful.client.movetotag(tags[client.focus.screen][i])
  433.                       end
  434.                   end),
  435.         awful.key({ modkey, "Control", "Shift" }, "#" .. i + 9,
  436.                   function ()
  437.                       if client.focus and tags[client.focus.screen][i] then
  438.                           awful.client.toggletag(tags[client.focus.screen][i])
  439.                       end
  440.                   end))
  441. end
  442.  
  443. clientbuttons = awful.util.table.join(
  444.     awful.button({ }, 1, function (c) client.focus = c; c:raise() end),
  445.     awful.button({ modkey }, 1, awful.mouse.client.move),
  446.     awful.button({ modkey }, 3, awful.mouse.client.resize))
  447.  
  448. -- Set keys
  449. root.keys(globalkeys)
  450. -- }}}
  451.  
  452. -- {{{ Rules
  453. awful.rules.rules = {
  454.     -- All clients will match this rule.
  455.     { rule = { },
  456.       properties = { border_width = beautiful.border_width,
  457.                      border_color = beautiful.border_normal,
  458.                      focus = awful.client.focus.filter,
  459.                      keys = clientkeys,
  460.                      buttons = clientbuttons } },
  461.     { rule = { class = "MPlayer" },
  462.       properties = { floating = true } },
  463.     { rule = { class = "pinentry" },
  464.       properties = { floating = true } },
  465.     { rule = { class = "gimp" },
  466.       properties = { floating = true } },
  467.     -- Set Firefox to always map on tags number 2 of screen 1.
  468.     -- { rule = { class = "Firefox" },
  469.     --   properties = { tag = tags[1][2] } },
  470.    
  471.     { rule = { instance = "exe" },
  472.       properties = { floating = true } },
  473.  
  474.     { rule = { class = "Ario" },
  475.       properties = { floating = false } }
  476.  
  477.  
  478.  
  479. }
  480. -- }}}
  481.  
  482. -- {{{ Signals
  483. -- Signal function to execute when a new client appears.
  484. client.connect_signal("manage", function (c, startup)
  485.     -- Enable sloppy focus
  486.     c:connect_signal("mouse::enter", function(c)
  487.         if awful.layout.get(c.screen) ~= awful.layout.suit.magnifier
  488.             and awful.client.focus.filter(c) then
  489.             client.focus = c
  490.         end
  491.     end)
  492.  
  493.     if not startup then
  494.         -- Set the windows at the slave,
  495.         -- i.e. put it at the end of others instead of setting it master.
  496.         -- awful.client.setslave(c)
  497.  
  498.         -- Put windows in a smart way, only if they does not set an initial position.
  499.         if not c.size_hints.user_position and not c.size_hints.program_position then
  500.             awful.placement.no_overlap(c)
  501.             awful.placement.no_offscreen(c)
  502.         end
  503.     end
  504.  
  505.     local titlebars_enabled = false
  506.     if titlebars_enabled and (c.type == "normal" or c.type == "dialog") then
  507.         -- Widgets that are aligned to the left
  508.         local left_layout = wibox.layout.fixed.horizontal()
  509.         left_layout:add(awful.titlebar.widget.iconwidget(c))
  510.  
  511.         -- Widgets that are aligned to the right
  512.         local right_layout = wibox.layout.fixed.horizontal()
  513.         right_layout:add(awful.titlebar.widget.floatingbutton(c))
  514.         right_layout:add(awful.titlebar.widget.maximizedbutton(c))
  515.         right_layout:add(awful.titlebar.widget.stickybutton(c))
  516.         right_layout:add(awful.titlebar.widget.ontopbutton(c))
  517.         right_layout:add(awful.titlebar.widget.closebutton(c))
  518.  
  519.         -- The title goes in the middle
  520.         local title = awful.titlebar.widget.titlewidget(c)
  521.         title:buttons(awful.util.table.join(
  522.                 awful.button({ }, 1, function()
  523.                     client.focus = c
  524.                     c:raise()
  525.                     awful.mouse.client.move(c)
  526.                 end),
  527.                 awful.button({ }, 3, function()
  528.                     client.focus = c
  529.                     c:raise()
  530.                     awful.mouse.client.resize(c)
  531.                 end)
  532.                 ))
  533.  
  534.         -- Now bring it all together
  535.         local layout = wibox.layout.align.horizontal()
  536.         layout:set_left(left_layout)
  537.         layout:set_right(right_layout)
  538.         layout:set_middle(title)
  539.  
  540.         awful.titlebar(c):set_widget(layout)
  541.     end
  542. end)
  543.  
  544. client.connect_signal("focus", function(c) c.border_color = beautiful.border_focus end)
  545. client.connect_signal("unfocus", function(c) c.border_color = beautiful.border_normal end)
  546. -- }}}
  547.  
  548.  
  549.  
  550.  
  551.  
  552.  
  553.  
  554.  
  555. -- start local stuff
  556.  
  557. awful.util.spawn_with_shell("nm-applet")
  558. -- awful.util.spawn_with_shell("conky")
  559. awful.util.spawn_with_shell("cairo-compmgr")
  560. awful.util.spawn_with_shell("wmname LG3D")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement