Skip to content

Commit

Permalink
Merge pull request #10 from timroes/awesome4
Browse files Browse the repository at this point in the history
Awesome v4 config
  • Loading branch information
timroes authored Jun 2, 2017
2 parents 9f11c23 + 21cda96 commit c5b00cd
Show file tree
Hide file tree
Showing 57 changed files with 963 additions and 1,042 deletions.
7 changes: 7 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
root = true

[*.lua]
indent_style = tab
charset = utf-8
end_of_line = lf
insert_final_newline = true
9 changes: 7 additions & 2 deletions conf.d/00compositor.lua
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
local lunaconf = require('lunaconf')
local awful = require('awful')
local gears = require('gears')

if not lunaconf.config.get('disable_compositor', false) then
local function set_shadow_hint(c)
local no_shadow
if awful.client.floating.get(c) then
if c.floating then
no_shadow = 0
else
no_shadow = 1
Expand All @@ -13,11 +14,15 @@ if not lunaconf.config.get('disable_compositor', false) then
end

-- Shadow handling of compton
-- Disable shadows (set _COMPTON_NO_SHADOW xproperty) on all non floating windows
-- so they won't leave ugly shadows on the screen bar(s).
awesome.register_xproperty("_COMPTON_NO_SHADOW", "number")
client.connect_signal("manage", function(c, startup)
set_shadow_hint(c)
c:connect_signal("property::floating", set_shadow_hint)
end)

lunaconf.utils.run_once('compton --config ' .. awful.util.getdir('config') .. '/compton.conf -b')
if not awesome.composite_manager_running then
lunaconf.utils.run_once('compton --config ' .. gears.filesystem.get_configuration_dir() .. '/compton.conf -b')
end
end
62 changes: 28 additions & 34 deletions conf.d/01clients.lua
Original file line number Diff line number Diff line change
@@ -1,34 +1,31 @@
local awful = require("awful")
local lunaconf = require("lunaconf")
local gears = require('gears')

local MOD = lunaconf.config.MOD

local move_client = function(c, direction)
-- If client is unmoveable don't do anything
if awful.client.property.get(c, "client::unmoveable") then
return
end

local cur_tag = awful.tag.selected(c.screen)
local cur_tag = c.screen.selected_tag

-- Only allow window move for windows on not named tags
if #cur_tag.name <= 1 then
local new_screen = ((c.screen - 1 + direction) % screen.count()) + 1
local new_tag = default_tag_for_screen(new_screen)
awful.client.movetotag(new_tag, c)
if cur_tag.is_primary then
local new_screen = c.screen:get_next_in_direction(direction)
if new_screen then
c:move_to_tag(new_screen.primary_tag)
end
end
end

-- Define buttons for every client
buttons = awful.util.table.join(
buttons = gears.table.join(
awful.button({ }, 1, function(c) client.focus = c; c:raise() end),
awful.button({ MOD }, 1, function(c)
lunaconf.clients.smart_move(c)
end),
awful.button({ MOD }, 2, function(c) c:kill() end),
awful.button({ MOD }, 3, function(c)
-- Resizing of clients on modifier + right mouse button
if string.starts(awful.layout.get(c.screen).name, "tile") then
if lunaconf.strings.starts_with(awful.layout.get(c.screen).name, "tile") then
-- If client on a split screen is tried to rescale we modify the split factor instead
mousegrabber.run(function(ev)
local s = screen[c.screen] -- current screen
Expand All @@ -45,8 +42,8 @@ buttons = awful.util.table.join(
end, "sb_h_double_arrow")
else
-- On any non tiling screen we make the client floating and start resize mode
if not lunaconf.clients.get_attr(c, 'unresizeable', false) then
awful.client.floating.set(c, true)
if not c.unresizeable then
c.floating = true
awful.mouse.client.resize(c)
end
end
Expand All @@ -56,17 +53,16 @@ buttons = awful.util.table.join(
-- Define keys for every client
-- Keys depending on direct tag access (Mod + .. + Number) are
-- defined in the tags configuration file
keys = awful.util.table.join(
keys = gears.table.join(
-- close client
awful.key({ MOD }, "q", function(c) c:kill() end),
awful.key({ "Mod1" }, "F4", function(c) c:kill() end),

-- move client to other screen/tag
awful.key({ MOD }, "Right", function(c) move_client(c, 1) end),
awful.key({ MOD }, "Left", function(c) move_client(c, -1) end),

-- Minimize current window
awful.key({ MOD }, "Down", function(c) c.minimized = true end),
awful.key({ MOD }, "Right", function(c) move_client(c, 'right') end),
awful.key({ MOD }, "Left", function(c) move_client(c, 'left') end),
awful.key({ MOD }, "Down", function(c) move_client(c, 'down') end),
awful.key({ MOD }, "Up", function(c) move_client(c, 'up') end),

-- swap clients into direction (only works in split mode (see tags.lua))
awful.key({ MOD, "Control" }, "Right", function(c) awful.client.swap.bydirection("right") end),
Expand All @@ -76,7 +72,7 @@ keys = awful.util.table.join(

-- toggle client floating state
awful.key({ MOD }, "Return", function(c)
if not lunaconf.clients.get_attr(c, 'unresizeable', false) then
if not c.unresizeable then
awful.client.floating.toggle(c)
end
end),
Expand All @@ -100,11 +96,13 @@ awful.rules.rules = {
properties = {
floating = true,
}
},{
rule = { type = "dialog" },
callback = function(c)
awful.placement.centered(c,nil)
end
},
{
rule_any = { type = { 'dialog' }, role = { 'pop-up' } },
properties = {
floating = true,
placement = awful.placement.centered
}
}
}

Expand All @@ -124,7 +122,7 @@ client.connect_signal("manage", function(c, startup)
-- out a tab, so make it floating, so chromium can control its position
-- while we drag it to its final position
if under_mouse and under_mouse.pid == c.pid then
awful.client.floating.set(c, true)
c.floating = true
end
end

Expand All @@ -135,25 +133,21 @@ client.connect_signal("manage", function(c, startup)
c.maximized_vertical = false
c.maximized_horizontal = false

if c.role == "pop-up" then
awful.client.floating.set(c, true)
end

if c.size_hints then
local sh = c.size_hints
local wa = screen[c.screen].workarea
if sh.user_size and sh.user_size.width ~= wa.width and sh.user_size.height ~= wa.height then
-- If the user size hint is set, make the window floating and give it the specific size
-- unless the size matches exactly the size of the workarea, in this case leave it fullscreen.
awful.client.floating.set(c, true)
c.floating = true
c:geometry(sh.user_size)
awful.placement.centered(c, nil)
elseif sh.max_height and sh.max_width and sh.max_height == sh.min_height and sh.min_width == sh.max_width then
-- Check if the client has a program set minimum and maximum size, that are equal
-- If so, treat this client as a dialog window (center it and make it floating)
-- Also make it unresizeable (also meaning it cannot be unfloated)
lunaconf.clients.set_attr(c, 'unresizeable', true)
awful.client.floating.set(c, true)
c.unresizeable = true
c.floating = true
awful.placement.centered(c, nil)
end
end
Expand Down
15 changes: 7 additions & 8 deletions conf.d/02keys.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,21 @@ local MOD = lunaconf.config.MOD
lunaconf.keys.globals(
-- System shortcuts
awful.key({ MOD, "Control"}, "Delete", function()
restart = true
awesome.restart()
end),

-- Start programs
awful.key({ MOD }, "z", function() awful.util.spawn_with_shell("xdg-open $HOME") end),
awful.key({ MOD }, "z", function() lunaconf.utils.spawn("xdg-open $HOME") end),

-- Screenshots
awful.key({ 'Mod1' }, "Print", function() awful.util.spawn(scriptpath .. "screenshot win") end),
awful.key({ MOD }, "Print", function() awful.util.spawn(scriptpath .. "screenshot scr") end),
awful.key({ 'Mod1' }, "Print", function() awful.spawn.spawn(lunaconf.utils.scriptpath() .. "screenshot win") end),
awful.key({ MOD }, "Print", function() awful.spawn.spawn(lunaconf.utils.scriptpath() .. "screenshot scr") end),

-- Brightness Control
awful.key({}, 'XF86MonBrightnessUp', function() awful.util.spawn(scriptpath .. "brightness.sh up") end),
awful.key({ 'Shift' }, 'XF86MonBrightnessUp', function() awful.util.spawn(scriptpath .. "brightness.sh up small") end),
awful.key({}, 'XF86MonBrightnessDown', function() awful.util.spawn(scriptpath .. "brightness.sh down") end),
awful.key({ 'Shift' }, 'XF86MonBrightnessDown', function() awful.util.spawn(scriptpath .. "brightness.sh down small") end),
awful.key({}, 'XF86MonBrightnessUp', function() awful.spawn.spawn(lunaconf.utils.scriptpath() .. "brightness.sh up") end),
awful.key({ 'Shift' }, 'XF86MonBrightnessUp', function() awful.spawn.spawn(lunaconf.utils.scriptpath() .. "brightness.sh up small") end),
awful.key({}, 'XF86MonBrightnessDown', function() awful.spawn.spawn(lunaconf.utils.scriptpath() .. "brightness.sh down") end),
awful.key({ 'Shift' }, 'XF86MonBrightnessDown', function() awful.spawn.spawn(lunaconf.utils.scriptpath() .. "brightness.sh down small") end),

-- MOD + PageUp/PageDown switches through clients on current tag and screen
awful.key({ MOD }, "Page_Up", function()
Expand Down
17 changes: 17 additions & 0 deletions conf.d/03urgent.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
-- This configuration handles urgent clients (clients with demands_attention hint).

local awful = require('awful')
local lunaconf = require('lunaconf')

local function jump_to_urgent()
local next_urgent = awful.client.urgent.get()
if next_urgent then
client.focus = next_urgent
next_urgent:raise()
end
end

-- On MOD + backslash jump to next window that has the urgent hint set
lunaconf.keys.globals(
awful.key({ lunaconf.config.MOD }, '\\', jump_to_urgent)
)
93 changes: 54 additions & 39 deletions conf.d/04tags.lua
Original file line number Diff line number Diff line change
@@ -1,62 +1,77 @@
local awful = require("awful")
local config = require("lunaconf.config")
local awful = require('awful')
local lunaconf = require('lunaconf')

local layouts = {
awful.layout.suit.max,
awful.layout.suit.tile.right
}

tags = {}
tag_keys = root.keys()
local screens_in_order = {}

for s = 1, screen.count() do
-- Get name for screen tag (horizontal position of screen)
local tagname = screen_position(s)
-- Create tag for that name and select it
local tag = awful.tag.add(tagname, { screen = s, layout = layouts[1], screen_tag = true })
tag.selected = true
-- Create the primary tag on each screen
awful.screen.connect_for_each_screen(function(s)
-- Create the new primary tag for this screen (leave it's name empty yet)
-- since the screen.list signal will take care renaming it in a moment
local tag = awful.tag.add('-', {
screen = s, -- Set the screen to the current
layout = layouts[1], -- Set its layout to the default layout
is_primary = true, -- Add a custom flag to mark it as the primary for this screen
selected = true
})
-- Attach the tag as the primary tag to the given screen
s.primary_tag = tag
end)

-- Switch to tag
local tagFocus = function()
if client.focus and client.focus.screen == s and awful.tag.selected(s) == tag then
--- Iterate over all screens and give their primary tag the name of their screen
--- position. Also save this renamed order in screens_in_order, which will be
--- used to lookup the screens in hotkeys.
local function rename_screen_tags()
screens_in_order = {}
lunaconf.screens.iterate_in_order(function(pos, s)
screens_in_order[pos] = s
s.primary_tag.name = tostring(pos)
end)
end

-- Rename screen tags if screen list changes or if the geometry of a screen changes
screen.connect_signal('list', rename_screen_tags)
screen.connect_signal('property::geometry', rename_screen_tags)
rename_screen_tags()

local function focus_tag(screen_position)
local s = screens_in_order[screen_position]
-- Ignore key presses if there is no screen with that position
if s then
if client.focus and client.focus.screen == s and s.selected_tag == s.primary_tag then
-- If screen is already focused switch to next client
awful.client.focus.byidx(1)
if client.focus then client.focus:raise() end
else
if not tag.selected then
awful.tag.viewmore({ tag }, s)
if not s.primary_tag.selected then
awful.tag.viewmore({ s.primary_tag }, s)
end
-- Focus last focused client on this tag
local focus = awful.client.focus.history.get(s, 0)
if focus then client.focus = focus end
end
end
-- Move to tag
local moveToTag = function()
if not client.focus then return end
awful.client.movetotag(tag, client.focus)
end
end

-- Assign key shortcuts for every tag
tag_keys = awful.util.table.join(tag_keys,
-- Switch to tag
awful.key({ config.MOD }, "#" .. tagname + 9, tagFocus), -- Numbers
awful.key({ config.MOD }, "#" .. tagname + 86, tagFocus), -- Numpad keys
-- Move client to tag
awful.key({ config.MOD, "Control" }, "#" .. tagname + 9, moveToTag),
awful.key({ config.MOD, "Control" }, "#" .. tagname + 86, moveToTag)
)
-- Add hotkeys to navigate to screens between 1 and 9
for i = 1, 9 do
local key = awful.key({ lunaconf.config.MOD }, '#' .. i + 9, function()
focus_tag(i)
end)
lunaconf.keys.globals(key)
end

tag_keys = awful.util.table.join(tag_keys,
-- Switch layouts for the current screen
awful.key({ config.MOD }, "s", function()
-- Only allow split screen on regular (screen) tags
local cur_tag = awful.tag.selected(client.focus.screen)
if #cur_tag.name <= 1 then
awful.layout.inc(layouts, 1, client.focus.screen)
end
end)
)
local switch_layout = awful.key({ lunaconf.config.MOD }, "s", function()
-- Only allow split screen on screen tags
local cur_tag = client.focus.screen.selected_tag
if cur_tag.is_primary then
awful.layout.inc(layouts, 1, client.focus.screen)
end
end)

root.keys(tag_keys)
lunaconf.keys.globals(switch_layout)
Loading

0 comments on commit c5b00cd

Please sign in to comment.