Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require('awful')
- require('awful.rules')
- require('awful.autofocus')
- require('beautiful')
- require('eminent')
- require('naughty')
- -- Constants
- terminal = 'gnome-terminal'
- editor = 'gvim'
- modkey = 'Mod4'
- dmenu = 'dmenu_run -p "command:" -nb "#222222" -nf "#808080" -sb "#256fb4" -sf "#ffffff" -l 10 -fn "-misc-fixed-medium-*-normal-*-14-*-*-*-*-*-*-*"'
- system_tray_screen = 1
- widgets_screen = 1
- cursor_name = 'left_ptr'
- if screen.count() > 1 then
- widgets_screen = 2
- end
- -- Set root cursor
- root.cursor(cursor_name)
- -- Function used to focus clients on workspace change
- function focus_screen(screen_index)
- if screen_index ~= mouse.screen then
- local pos_x = math.floor(screen[screen_index].workarea.width / 2)
- local pos_y = math.floor(screen[screen_index].workarea.height / 2)
- pos_x = pos_x + screen[screen_index].geometry.x
- pos_y = pos_y + screen[screen_index].geometry.y
- awful.screen.focus(screen_index)
- mouse.coords({x = pos_x, y = pos_y}, false)
- end
- end
- -- Initialize default theme
- theme_path = '/usr/share/awesome/themes/default/theme.lua'
- theme_path = '/home/meaneye/.config/awesome/wave/theme.lua'
- beautiful.init(theme_path)
- awesome.font = 'Ubuntu 9'
- theme.font = awesome.font
- theme.taglist_font = awesome.font
- -- Table of layouts to cover with awful.layout.inc, order matters.
- layouts = {
- awful.layout.suit.tile,
- awful.layout.suit.tile.left,
- awful.layout.suit.tile.bottom,
- awful.layout.suit.tile.top,
- awful.layout.suit.fair,
- awful.layout.suit.fair.horizontal,
- awful.layout.suit.max
- }
- -- Configure tags for each screen
- tags = {}
- tags_by_name = {}
- if screen.count() == 2 then
- -- Create tags for each screen individually
- tags[1] = awful.tag({'Web', 'FM', 6, 7, 8, 9}, 1, layouts[1])
- tags[2] = awful.tag({'Chat', 'Code', 'Misc', 6, 7, 8, 9}, 2, layouts[1])
- tags_by_name.chat = tags[2][1]
- tags_by_name.web = tags[1][1]
- tags_by_name.code = tags[2][2]
- tags_by_name.misc = tags[2][3]
- tags_by_name.fm = tags[1][2]
- elseif screen.count() == 3 then
- -- Create tags for each screen individually
- tags[1] = awful.tag({'Web', 'FM', 6, 7, 8, 9}, 1, layouts[1])
- tags[2] = awful.tag({'Chat', 'Code', 'Misc', 6, 7, 8, 9}, 2, layouts[1])
- tags[3] = awful.tag({'TV'}, 3, layouts[1])
- tags_by_name.chat = tags[2][1]
- tags_by_name.web = tags[1][1]
- tags_by_name.code = tags[2][2]
- tags_by_name.misc = tags[2][3]
- tags_by_name.fm = tags[1][2]
- else
- -- We are operating on a single screen
- tags[1] = awful.tag({'Chat', 'Web', 'Code', 'Misc', 'FM', 6, 7, 8, 9}, 1, layouts[1])
- tags_by_name.chat = tags[1][1]
- tags_by_name.web = tags[1][2]
- tags_by_name.code = tags[1][3]
- tags_by_name.misc = tags[1][4]
- tags_by_name.fm = tags[1][5]
- end
- -- Create widgets
- items_main_menu = {
- {'Terminal', terminal},
- {'Sunflower', 'sunflower'},
- {'Restart', awesome.restart},
- {'Logout', awesome.quit}
- }
- main_menu = awful.menu({items = items_main_menu})
- launcher_main_menu = awful.widget.launcher({image = image(beautiful.awesome_icon), menu = main_menu})
- -- Create system tray
- system_tray = widget({type ='systray'})
- -- Create tag lists
- tag_list = {}
- tag_list.buttons = awful.util.table.join(
- awful.button({}, 1, awful.tag.viewonly),
- awful.button({modkey}, 1, awful.client.movetotag),
- awful.button({}, 3, awful.tag.viewtoggle),
- awful.button({modkey}, 3, awful.client.toggletag),
- awful.button({}, 4, awful.tag.viewprev),
- awful.button({}, 5, awful.tag.viewnext)
- )
- -- Create toolbar for each screen
- toolbars = {}
- layout_box = {}
- for screen_index = 1, screen.count() do
- options = {
- position = 'top',
- screen = screen_index,
- height = beautiful.bar_height,
- cursor = cursor_name
- }
- -- Create new toolbar (wibox)
- toolbars[screen_index] = awful.wibox(options)
- -- Create tag list for each screen
- tag_list[screen_index] = awful.widget.taglist(
- screen_index,
- awful.widget.taglist.label.all,
- tag_list.buttons
- )
- -- Create layout box which displays current layout of windows
- layout_box[screen_index] = awful.widget.layoutbox(screen_index)
- layout_box[screen_index]:buttons(awful.util.table.join(
- awful.button({}, 1, function() awful.layout.inc(layouts, 1) end),
- awful.button({}, 3, function() awful.layout.inc(layouts, -1) end),
- awful.button({}, 4, function() awful.layout.inc(layouts, 1) end),
- awful.button({}, 5, function() awful.layout.inc(layouts, -1) end))
- )
- toolbars[screen_index].widgets = {
- {
- launcher_main_menu,
- tag_list[screen_index],
- layout = awful.widget.layout.horizontal.leftright
- },
- layout_box[screen_index],
- screen_index == system_tray_screen and system_tray or nil,
- screen_index == widgets_screen and theme.widgets or nil,
- layout = awful.widget.layout.horizontal.rightleft
- }
- end
- -- Set key and mouse handlers
- container_buttons = awful.util.table.join(
- awful.button({}, 1, function(container) client.focus = container; container:raise() end),
- awful.button({modkey}, 1, awful.mouse.client.move),
- awful.button({modkey}, 3, awful.mouse.client.resize)
- )
- container_keys = awful.util.table.join(
- awful.key({'Mod1'}, 'F4', function(container) container:kill() end),
- awful.key({modkey, 'Shift'}, 'space', awful.client.floating.toggle),
- awful.key({modkey}, 'f', function(container) container.fullscreen = not container.fullscreen end),
- awful.key({modkey}, 'm', function(container)
- container.maximized_horizontal = not container.maximized_horizontal
- container.maximized_vertical = not container.maximized_vertical
- end)
- )
- global_keys = awful.util.table.join(
- awful.key({modkey}, 'F1', function() awful.util.spawn(terminal) end),
- awful.key({modkey}, 'F2', function() awful.util.spawn(editor) end),
- awful.key({'Mod1'}, 'F2', function() awful.util.spawn(dmenu) end),
- awful.key({modkey, 'Shift'}, 'r', awesome.restart),
- awful.key({modkey}, 'Return', function() awful.layout.inc(layouts, 1) end),
- awful.key({modkey, 'Shift'}, 'Return', function() awful.layout.inc(layouts, -1) end),
- awful.key({'Mod1'}, 'Tab', function()
- awful.client.focus.history.previous()
- if client.focus then
- client.focus:raise()
- end
- end),
- awful.key({modkey}, 'Right', function()
- awful.client.focus.bydirection('right')
- if client.focus then client.focus:raise() end
- end),
- awful.key({modkey}, 'Left', function()
- awful.client.focus.bydirection('left')
- if client.focus then client.focus:raise() end
- end),
- awful.key({modkey}, 'Up', function()
- awful.client.focus.bydirection('up')
- if client.focus then client.focus:raise() end
- end),
- awful.key({modkey}, 'Down', function()
- awful.client.focus.bydirection('down')
- if client.focus then client.focus:raise() end
- end),
- awful.key({modkey, 'Shift'}, 'Right', function()
- awful.client.swap.bydirection('right')
- if client.focus then client.focus:raise() end
- end),
- awful.key({modkey, 'Shift'}, 'Left', function()
- awful.client.swap.bydirection('left')
- if client.focus then client.focus:raise() end
- end),
- awful.key({modkey, 'Shift'}, 'Up', function()
- awful.client.swap.bydirection('up')
- if client.focus then client.focus:raise() end
- end),
- awful.key({modkey, 'Shift'}, 'Down', function()
- awful.client.swap.bydirection('down')
- if client.focus then client.focus:raise() end
- end),
- awful.key({modkey}, '1', function()
- awful.tag.viewonly(tags_by_name.chat)
- focus_screen(tags_by_name.chat.screen)
- end),
- awful.key({modkey}, '2', function()
- awful.tag.viewonly(tags_by_name.web)
- focus_screen(tags_by_name.web.screen)
- end),
- awful.key({modkey}, '3', function()
- awful.tag.viewonly(tags_by_name.code)
- focus_screen(tags_by_name.code.screen)
- end),
- awful.key({modkey}, '4', function()
- awful.tag.viewonly(tags_by_name.misc)
- focus_screen(tags_by_name.misc.screen)
- end),
- awful.key({modkey}, '5', function()
- awful.tag.viewonly(tags_by_name.fm)
- focus_screen(tags_by_name.fm.screen)
- end),
- awful.key({modkey, 'Shift'}, '1', function() awful.tag.movetotag(tags_by_name.chat) end),
- awful.key({modkey, 'Shift'}, '2', function() awful.tag.movetotag(tags_by_name.web) end),
- awful.key({modkey, 'Shift'}, '3', function() awful.tag.movetotag(tags_by_name.code) end),
- awful.key({modkey, 'Shift'}, '4', function() awful.tag.movetotag(tags_by_name.misc) end),
- awful.key({modkey, 'Shift'}, '5', function() awful.tag.movetotag(tags_by_name.fm) end)
- )
- -- Bind the rest of the numbers
- for index = 6, 9 do
- global_keys = awful.util.table.join(global_keys,
- awful.key({modkey}, index, function()
- local screen_count = screen.count()
- local screen = mouse.screen
- local tag_index = index
- if screen_count > 1 then
- tag_index = screen == 1 and index - 3 or index - 2
- end
- awful.tag.viewonly(tags[screen][tag_index])
- grab_focus()
- end))
- end
- -- Connect root keys and buttons
- root.buttons(awful.util.table.join(
- awful.button({}, 3, function () main_menu:toggle() end),
- awful.button({}, 4, awful.tag.viewnext),
- awful.button({}, 5, awful.tag.viewprev)
- ))
- root.keys(global_keys)
- -- Set general rules
- awful.rules.rules = {
- {
- rule = {},
- properties = {
- border_width = beautiful.border_width,
- border_color = beautiful.border_color,
- focus = true,
- keys = container_keys,
- buttons = container_buttons,
- size_hints_honor = false
- }
- },
- {
- rule = {class = "Pidgin"},
- properties = {
- tag = tags_by_name.chat
- }
- },
- {
- rule = {class = "Pidgin", role = "buddy_list"},
- properties = {
- floating = true
- },
- callback = function(container)
- local work_area = screen[container.screen].workarea
- local window_width = 250
- container:struts({right = window_width})
- container:geometry({
- x = work_area.width - window_width,
- width = window_width,
- y = work_area.y,
- height = work_area.height
- })
- end
- },
- {
- rule = {role = "irc_chat"},
- properties = {
- tag = tags_by_name.chat
- }
- },
- {
- rule = {role = "music_player"},
- properties = {
- tag = tags_by_name.chat
- }
- },
- {
- rule = {class = "Google-chrome"},
- properties = {
- tag = tags_by_name.web
- }
- },
- {
- rule = {class = "Gimp"},
- properties = {
- tag = tags_by_name.misc
- }
- },
- {
- rule = {class = "Bcompare"},
- properties = {
- tag = tags_by_name.misc
- }
- },
- {
- rule = {class = "Sunflower"},
- properties = {
- tag = tags_by_name.fm
- }
- }
- }
- -- Handle signals
- client.add_signal('manage', function (container, startup)
- -- Add a titlebar
- options = {
- modkey = modkey,
- height = 16
- }
- -- awful.titlebar.add(container, options)
- if not startup then
- -- Set the windows at the slave,
- -- i.e. put it at the end of others instead of setting it master.
- -- awful.client.setslave(c)
- -- Put windows in a smart way, only if they does not set an initial position.
- if not container.size_hints.user_position and not container.size_hints.program_position then
- awful.placement.no_overlap(container)
- awful.placement.no_offscreen(container)
- end
- end
- end)
- client.add_signal('focus', function(container) container.border_color = beautiful.border_focus end)
- client.add_signal('unfocus', function(container) container.border_color = beautiful.border_normal end)
- -- Execute required programs
- awful.util.spawn_with_shell('gnome-settings-daemon')
- awful.util.spawn_with_shell('bluetooth-applet')
- awful.util.spawn_with_shell('nm-applet')
- awful.util.spawn_with_shell('~/.mouse.sh')
- awful.util.spawn_with_shell('gnome-terminal -e irssi --role "irc_chat"')
- awful.util.spawn_with_shell('gnome-terminal -e cmus --role "music_player"')
- awful.util.spawn_with_shell('pidgin')
- awful.util.spawn_with_shell('sleep 2; google-chrome')
Add Comment
Please, Sign In to add comment