add layout env edge menu rules signal

This commit is contained in:
vincent 2019-10-19 18:52:29 +02:00
parent d32c5fd6b4
commit a345c86326
3 changed files with 103 additions and 258 deletions

View File

@ -5,7 +5,7 @@
-- @copyright 2017 ikselven
-- @module awful.hotkeys_popup.keys.termite
---------------------------------------------------------------------------
require("awful.hotkeys_popup.keys")
local hotkeys_popup = require("awful.hotkeys_popup.widget")
local termite_rule = { class = "Termite" }

View File

@ -1,6 +1,13 @@
-- Standard awesome library
local gears = require("gears")
local awful = require("awful")
-- User modules
------------------------------------------------------------
local redflat = require("redflat")
redflat.startup:activate()
require("awful.autofocus")
-- Widget and layout library
local wibox = require("wibox")
@ -14,114 +21,52 @@ local xrandr = require("xrandr")
local naughty = require("naughty")
local menubar = require("menubar")
--load revelation plugin
local revelation=require("revelation")
--load hotkey_popup
local hotkeys_popup = require("awful.hotkeys_popup").widget
-- Enable hotkeys help widget for VIM and other apps
-- when client with a matching name is opened:
require("awful.hotkeys_popup.keys")
require("hotkeys_popup.termite")
-- {{{ Error handling
-- Check if awesome encountered an error during startup and fell back to
-- another config (This code will only ever execute for the fallback config)
if awesome.startup_errors then
naughty.notify({ preset = naughty.config.presets.critical,
title = "Oops, there were errors during startup!",
text = awesome.startup_errors })
end
-- Error handling
-----------------------------------------------------------------------------------------------------------------------
require("ercheck-config") -- load file with error handling
-- Handle runtime errors after startup
do
local in_error = false
awesome.connect_signal("debug::error", function (err)
-- Make sure we don't go into an endless error loop
if in_error then return end
in_error = true
naughty.notify({ preset = naughty.config.presets.critical,
title = "Oops, an error happened!",
text = tostring(err) })
in_error = false
end)
end
-- }}}
-- {{{ Variable definitions
-- Themes define colours, icons, font and wallpapers.
beautiful.init(awful.util.getdir("config") .. "/themes/default/theme.lua")
beautiful.useless_gap = 5
env=require("env-config")
env:init()
-- revelation init
local revelation=require("revelation")
revelation.init()
--
-- This is used later as the default terminal and editor to run.
local terminal = "termite"
awful.util.terminal = terminal
editor = os.getenv("EDITOR") or "vim"
editor_cmd = terminal .. " -e " .. editor
editor_cmd = env.terminal .. " -e " .. editor
-- Default modkey.
-- Default env.mod.
-- Usually, Mod4 is the key with a logo between Control and Alt.
-- If you do not like this or do not have such a key,
-- I suggest you to remap Mod4 to another key using xmodmap or other tools.
-- However, you can use another modifier like Mod1, but it may interact with others.
modkey = "Mod4"
-- Table of layouts to cover with awful.layout.inc, order matters.
awful.layout.layouts = {
awful.layout.suit.floating,
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.spiral,
--awful.layout.suit.spiral.dwindle,
awful.layout.suit.max,
--awful.layout.suit.max.fullscreen,
--awful.layout.suit.magnifier,
awful.layout.suit.corner.nw,
awful.layout.suit.corner.ne,
-- awful.layout.suit.corner.sw,
-- awful.layout.suit.corner.se,
}
-- }}}
-- {{{ Helper functions
local function client_menu_toggle_fn()
local instance = nil
return function ()
if instance and instance.wibox.visible then
instance:hide()
instance = nil
else
instance = awful.menu.clients({ theme = { width = 250 } })
end
end
end
-- }}}
-- {{{ Menu
-- Create a launcher widget and a main menu
myawesomemenu = {
{ "hotkeys", function() return false, hotkeys_popup.show_help end},
{ "manual", terminal .. " -e man awesome" },
{ "edit config", editor_cmd .. " " .. awesome.conffile },
{ "restart", awesome.restart },
{ "quit", function() awesome.quit() end}
}
local mainmenu=require("menu")
mainmenu:init({ env = env })
mymainmenu = awful.menu({ items = { { "awesome", myawesomemenu, beautiful.awesome_icon },
{ "open terminal", terminal }
}
})
local layouts = require("layout-config") -- load file with tile layouts setup
layouts:init()
mylauncher = awful.widget.launcher({ image = beautiful.awesome_icon,
menu = mymainmenu })
--mylauncher = awful.widget.launcher({ image = beautiful.awesome_icon,
-- menu = mymainmenu })
-- Menubar configuration
menubar.utils.terminal = terminal -- Set the terminal for applications that require it
-- }}}
@ -133,7 +78,7 @@ mykeyboardlayout = awful.widget.keyboardlayout()
-- Create a textclock widget
mytextclock = wibox.widget.textclock()
local spr_right = wibox.widget.imagebox(beautiful.spr_right)
local spr_right = redflat.gauge.separator.vertical()
local cpuicon = wibox.widget.imagebox(beautiful.cpu_icon,true)
local cpu = lain.widget.cpu({
settings = function()
@ -206,13 +151,13 @@ local bat = lain.widget.bat({
-- Create a wibox for each screen and add it
local taglist_buttons = gears.table.join(
awful.button({ }, 1, function(t) t:view_only() end),
awful.button({ modkey }, 1, function(t)
awful.button({ env.mod }, 1, function(t)
if client.focus then
client.focus:move_to_tag(t)
end
end),
awful.button({ }, 3, awful.tag.viewtoggle),
awful.button({ modkey }, 3, function(t)
awful.button({ env.mod }, 3, function(t)
if client.focus then
client.focus:toggle_tag(t)
end
@ -242,7 +187,7 @@ awful.screen.connect_for_each_screen(function(s)
set_wallpaper(s)
-- Each screen has its own tag taawful.util.terminable.
awful.tag({ "1", "2", "3", "4", "5", "6", "7", "8", "9" }, s, awful.layout.layouts[2])
awful.tag({ "1", "2", "3", "4", "5", "6", "7", "8", "9" }, s, awful.layout.layouts[3])
-- Create a promptbox for each screen
@ -266,7 +211,6 @@ awful.screen.connect_for_each_screen(function(s)
layout = wibox.layout.align.horizontal,
{ -- Left widgets
layout = wibox.layout.fixed.horizontal,
mylauncher,
s.mytaglist,
s.mypromptbox,
spr_right,
@ -276,7 +220,6 @@ awful.screen.connect_for_each_screen(function(s)
nil -- Middle widget
,{ -- Right widgets
layout = wibox.layout.fixed.horizontal,
myredshift_stack,
spr_right,
netdownicon,
netdowninfo,
@ -288,8 +231,11 @@ awful.screen.connect_for_each_screen(function(s)
mymem,
baticon,
bat,
spr_right,
mykeyboardlayout,
spr_right,
wibox.widget.systray(),
spr_right,
mytextclock,
s.mylayoutbox,
},
@ -299,7 +245,7 @@ end)
-- {{{ Mouse bindings
root.buttons(gears.table.join(
awful.button({ }, 3, function () mymainmenu:toggle() end),
awful.button({ }, 3, function () mainmenu.mainmenu:toggle() end),
awful.button({ }, 4, awful.tag.viewnext),
awful.button({ }, 5, awful.tag.viewprev)
))
@ -307,49 +253,49 @@ root.buttons(gears.table.join(
-- {{{ Key bindings
globalkeys = gears.table.join(
awful.key({ modkey }, "b", function ()
awful.key({ env.mod }, "b", function ()
mouse.screen.mywibox.visible = not mouse.screen.mywibox.visible
end,{description="toble wibox",group="awesome"}),
awful.key({ modkey, }, "s", hotkeys_popup.show_help,
end,{description="togle wibox",group="awesome"}),
awful.key({ env.mod, }, "s", hotkeys_popup.show_help,
{description="show help", group="awesome"}),
awful.key({ modkey, }, "e", revelation,
awful.key({ env.mod, }, "e", revelation,
{description="revelation shortcut",group="awesome"}),
awful.key({ modkey, }, "Left", awful.tag.viewprev,
awful.key({ env.mod, }, "Left", awful.tag.viewprev,
{description = "view previous", group = "tag"}),
awful.key({ modkey, }, "Right", awful.tag.viewnext,
awful.key({ env.mod, }, "Right", awful.tag.viewnext,
{description = "view next", group = "tag"}),
awful.key({ modkey, }, "Escape", awful.tag.history.restore,
awful.key({ env.mod, }, "Escape", awful.tag.history.restore,
{description = "go back", group = "tag"}),
awful.key({ "Shift" }, "Alt_L", function() mykeyboardlayout.next_layout(); end),
awful.key({ modkey, }, "j",
awful.key({ env.mod, }, "j",
function ()
awful.client.focus.byidx( 1)
end,
{description = "focus next by index", group = "client"}
),
awful.key({ modkey, }, "k",
awful.key({ env.mod, }, "k",
function ()
awful.client.focus.byidx(-1)
end,
{description = "focus previous by index", group = "client"}
),
awful.key({modkey,"Shift"},"o" , function() xrandr.xrandr() end,
awful.key({env.mod,"Shift"},"o" , function() xrandr.xrandr() end,
{description = "xrandr shortcut", group = "awesome"}),
awful.key({ modkey, }, "w", function () mymainmenu:show() end,
awful.key({ env.mod, }, "w", function () mainmenu.mainmenu:show() end,
{description = "show main menu", group = "awesome"}),
-- Layout manipulation
awful.key({ modkey, "Shift" }, "j", function () awful.client.swap.byidx( 1) end,
awful.key({ env.mod, "Shift" }, "j", function () awful.client.swap.byidx( 1) end,
{description = "swap with next client by index", group = "client"}),
awful.key({ modkey, "Shift" }, "k", function () awful.client.swap.byidx( -1) end,
awful.key({ env.mod, "Shift" }, "k", function () awful.client.swap.byidx( -1) end,
{description = "swap with previous client by index", group = "client"}),
awful.key({ modkey, "Control" }, "j", function () awful.screen.focus_relative( 1) end,
awful.key({ env.mod, "Control" }, "j", function () awful.screen.focus_relative( 1) end,
{description = "focus the next screen", group = "screen"}),
awful.key({ modkey, "Control" }, "k", function () awful.screen.focus_relative(-1) end,
awful.key({ env.mod, "Control" }, "k", function () awful.screen.focus_relative(-1) end,
{description = "focus the previous screen", group = "screen"}),
awful.key({ modkey, }, "u", awful.client.urgent.jumpto,
awful.key({ env.mod, }, "u", awful.client.urgent.jumpto,
{description = "jump to urgent client", group = "client"}),
awful.key({ modkey, }, "Tab",
awful.key({ env.mod, }, "Tab",
function ()
awful.client.focus.history.previous()
if client.focus then
@ -360,31 +306,31 @@ globalkeys = gears.table.join(
-- Standard program
-- Dropdown application
awful.key({ modkey, }, "Return", function () awful.spawn(terminal) end,
awful.key({ env.mod, }, "Return", function () awful.spawn(terminal) end,
{description = "open a terminal", group = "launcher"}),
awful.key({ modkey, "Control" }, "r", awesome.restart,
awful.key({ env.mod, "Control" }, "r", awesome.restart,
{description = "reload awesome", group = "awesome"}),
awful.key({ modkey, "Shift" }, "q", awesome.quit,
awful.key({ env.mod, "Shift" }, "q", awesome.quit,
{description = "quit awesome", group = "awesome"}),
awful.key({ modkey, }, "l", function () awful.tag.incmwfact( 0.05) end,
awful.key({ env.mod, }, "l", function () awful.tag.incmwfact( 0.05) end,
{description = "increase master width factor", group = "layout"}),
awful.key({ modkey, }, "h", function () awful.tag.incmwfact(-0.05) end,
awful.key({ env.mod, }, "h", function () awful.tag.incmwfact(-0.05) end,
{description = "decrease master width factor", group = "layout"}),
awful.key({ modkey, "Shift" }, "h", function () awful.tag.incnmaster( 1, nil, true) end,
awful.key({ env.mod, "Shift" }, "h", function () awful.tag.incnmaster( 1, nil, true) end,
{description = "increase the number of master clients", group = "layout"}),
awful.key({ modkey, "Shift" }, "l", function () awful.tag.incnmaster(-1, nil, true) end,
awful.key({ env.mod, "Shift" }, "l", function () awful.tag.incnmaster(-1, nil, true) end,
{description = "decrease the number of master clients", group = "layout"}),
awful.key({ modkey, "Control" }, "h", function () awful.tag.incncol( 1, nil, true) end,
awful.key({ env.mod, "Control" }, "h", function () awful.tag.incncol( 1, nil, true) end,
{description = "increase the number of columns", group = "layout"}),
awful.key({ modkey, "Control" }, "l", function () awful.tag.incncol(-1, nil, true) end,
awful.key({ env.mod, "Control" }, "l", function () awful.tag.incncol(-1, nil, true) end,
{description = "decrease the number of columns", group = "layout"}),
awful.key({ modkey, }, "space", function () awful.layout.inc( 1) end,
awful.key({ env.mod, }, "space", function () awful.layout.inc( 1) end,
{description = "select next", group = "layout"}),
awful.key({ modkey, "Shift" }, "space", function () awful.layout.inc(-1) end,
awful.key({ env.mod, "Shift" }, "space", function () awful.layout.inc(-1) end,
{description = "select previous", group = "layout"}),
awful.key({ modkey, "Control" }, "n",
awful.key({ env.mod, "Control" }, "n",
function ()
local c = awful.client.restore()
-- Focus restored client
@ -396,10 +342,10 @@ globalkeys = gears.table.join(
{description = "restore minimized", group = "client"}),
-- Prompt
awful.key({ modkey }, "r", function () awful.screen.focused().mypromptbox:run() end,
awful.key({ env.mod }, "r", function () awful.screen.focused().mypromptbox:run() end,
{description = "run prompt", group = "launcher"}),
awful.key({ modkey }, "x",
awful.key({ env.mod }, "x",
function ()
awful.prompt.run {
prompt = "Run Lua code: ",
@ -410,7 +356,7 @@ globalkeys = gears.table.join(
end,
{description = "lua execute prompt", group = "awesome"}),
-- Menubar
awful.key({ modkey }, "p", function() menubar.show() end,
awful.key({ env.mod }, "p", function() menubar.show() end,
{description = "show the menubar", group = "launcher"}),
awful.key({ },"XF86AudioRaiseVolume", function() awful.spawn("pamixer -i 5") end),
awful.key({ }, "XF86AudioLowerVolume", function () awful.spawn("pamixer -d 5") end),
@ -436,42 +382,42 @@ globalkeys = gears.table.join(
)
clientkeys = gears.table.join(
awful.key({ modkey, }, "f",
awful.key({ env.mod, }, "f",
function (c)
c.fullscreen = not c.fullscreen
c:raise()
end,
{description = "toggle fullscreen", group = "client"}),
awful.key({ modkey, "Shift" }, "c", function (c) c:kill() end,
awful.key({ env.mod, "Shift" }, "c", function (c) c:kill() end,
{description = "close", group = "client"}),
awful.key({ modkey, "Control" }, "space", awful.client.floating.toggle ,
awful.key({ env.mod, "Control" }, "space", awful.client.floating.toggle ,
{description = "toggle floating", group = "client"}),
awful.key({ modkey, "Control" }, "Return", function (c) c:swap(awful.client.getmaster()) end,
awful.key({ env.mod, "Control" }, "Return", function (c) c:swap(awful.client.getmaster()) end,
{description = "move to master", group = "client"}),
awful.key({ modkey, }, "o", function (c) c:move_to_screen() end,
awful.key({ env.mod, }, "o", function (c) c:move_to_screen() end,
{description = "move to screen", group = "client"}),
awful.key({ modkey, }, "t", function (c) c.ontop = not c.ontop end,
awful.key({ env.mod, }, "t", function (c) c.ontop = not c.ontop end,
{description = "toggle keep on top", group = "client"}),
awful.key({ modkey, }, "n",
awful.key({ env.mod, }, "n",
function (c)
-- The client currently has the input focus, so it cannot be
-- minimized, since minimized clients can't have the focus.
c.minimized = true
end ,
{description = "minimize", group = "client"}),
awful.key({ modkey, }, "m",
awful.key({ env.mod, }, "m",
function (c)
c.maximized = not c.maximized
c:raise()
end ,
{description = "(un)maximize", group = "client"}),
awful.key({ modkey, "Control" }, "m",
awful.key({ env.mod, "Control" }, "m",
function (c)
c.maximized_vertical = not c.maximized_vertical
c:raise()
end ,
{description = "(un)maximize vertically", group = "client"}),
awful.key({ modkey, "Shift" }, "m",
awful.key({ env.mod, "Shift" }, "m",
function (c)
c.maximized_horizontal = not c.maximized_horizontal
c:raise()
@ -485,7 +431,7 @@ clientkeys = gears.table.join(
for i = 1, 9 do
globalkeys = gears.table.join(globalkeys,
-- View tag only.
awful.key({ modkey }, "#" .. i + 9,
awful.key({ env.mod }, "#" .. i + 9,
function ()
local screen = awful.screen.focused()
local tag = screen.tags[i]
@ -495,7 +441,7 @@ for i = 1, 9 do
end,
{description = "view tag #"..i, group = "tag"}),
-- Toggle tag display.
awful.key({ modkey, "Control" }, "#" .. i + 9,
awful.key({ env.mod, "Control" }, "#" .. i + 9,
function ()
local screen = awful.screen.focused()
local tag = screen.tags[i]
@ -505,7 +451,7 @@ for i = 1, 9 do
end,
{description = "toggle tag #" .. i, group = "tag"}),
-- Move client to tag.
awful.key({ modkey, "Shift" }, "#" .. i + 9,
awful.key({ env.mod, "Shift" }, "#" .. i + 9,
function ()
if client.focus then
local tag = client.focus.screen.tags[i]
@ -516,7 +462,7 @@ for i = 1, 9 do
end,
{description = "move focused client to tag #"..i, group = "tag"}),
-- Toggle tag on focused client.
awful.key({ modkey, "Control", "Shift" }, "#" .. i + 9,
awful.key({ env.mod, "Control", "Shift" }, "#" .. i + 9,
function ()
if client.focus then
local tag = client.focus.screen.tags[i]
@ -531,140 +477,37 @@ end
clientbuttons = gears.table.join(
awful.button({ }, 1, function (c) client.focus = c; c:raise() end),
awful.button({ modkey }, 1, awful.mouse.client.move),
awful.button({ modkey }, 3, awful.mouse.client.resize))
awful.button({ env.mod }, 1, awful.mouse.client.move),
awful.button({ env.mod }, 3, awful.mouse.client.resize))
-- Active screen edges
-----------------------------------------------------------------------------------------------------------------------
local edges = require("edges-config") -- load file with edges configuration
edges:init()
-- Set keys
root.keys(globalkeys)
-- }}}
local hotkeys = require("keys-config") -- load file with hotkeys configuration
hotkeys:init({ env = env, menu = mainmenu.mainmenu })
-- {{{ Rules
-- Rules to apply to new clients (through the "manage" signal).
awful.rules.rules = {
-- All clients will match this rule.
{ rule = { },
properties = { border_width = beautiful.border_width,
border_color = beautiful.border_normal,
focus = awful.client.focus.filter,
raise = true,
keys = clientkeys,
buttons = clientbuttons,
screen = awful.screen.preferred,
placement = awful.placement.no_overlap+awful.placement.no_offscreen
}
},
local rules = require("rules-config") -- load file with rules configuration
rules:init({ hotkeys = hotkeys})
-- Floating clients.
{ rule_any = {
instance = {
"DTA", -- Firefox addon DownThemAll.
"copyq", -- Includes session name in class.
},
class = {
"Arandr",
"Gpick",
"Kruler",
"MessageWin", -- kalarm.
"Sxiv",
"Wpa_gui",
"pinentry",
"veromix",
"xtightvncviewer",
"keepassxc",
},
name = {
"Calculatrice",
"Event Tester", -- xev.
},
role = {
"AlarmWindow", -- Thunderbird's calendar.
"pop-up", -- e.g. Google Chrome's (detached) Developer Tools.
}
}, properties = { floating = true,
ontop=true
}
},
-- Add titlebars to normal clients and dialogs
{ rule_any = {type = { "normal", "dialog" }
}, properties = { titlebars_enabled = true }
},
-- Set Firefox to always map on the tag named "2" on screen 1.
-- { rule = { class = "Firefox" },
-- properties = { screen = 1, tag = "2" } },
}
-- }}}
-- Titlebar setup
-----------------------------------------------------------------------------------------------------------------------
local titlebar = require("titlebar-config") -- load file with titlebar configuration
titlebar:init()
-- {{{ Signals
-- Signal function to execute when a new client appears.
client.connect_signal("manage", function (c)
-- Set the windows at the slave,
-- i.e. put it at the end of others instead of setting it master.
-- if not awesome.startup then awful.client.setslave(c) end
-- Base signal set for awesome wm
-----------------------------------------------------------------------------------------------------------------------
local signals = require("signals-config") -- load file with signals configuration
signals:init({ env = env })
if awesome.startup and
not c.size_hints.user_position
and not c.size_hints.program_position then
-- Prevent clients from being unreachable after screen count changes.
awful.placement.no_offscreen(c)
end
end)
-- Add a titlebar if titlebars_enabled is set to true in the rules.
client.connect_signal("request::titlebars", function(c)
-- buttons for the titlebar
local buttons = gears.table.join(
awful.button({ }, 1, function()
client.focus = c
c:raise()
awful.mouse.client.move(c)
end),
awful.button({ }, 3, function()
client.focus = c
c:raise()
awful.mouse.client.resize(c)
end)
)
awful.titlebar(c) : setup {
{ -- Left
awful.titlebar.widget.iconwidget(c),
buttons = buttons,
layout = wibox.layout.fixed.horizontal
},
{ -- Middle
{ -- Title
align = "center",
widget = awful.titlebar.widget.titlewidget(c)
},
buttons = buttons,
layout = wibox.layout.flex.horizontal
},
{ -- Right
awful.titlebar.widget.floatingbutton (c),
awful.titlebar.widget.maximizedbutton(c),
awful.titlebar.widget.stickybutton (c),
awful.titlebar.widget.ontopbutton (c),
awful.titlebar.widget.closebutton (c),
layout = wibox.layout.fixed.horizontal()
},
layout = wibox.layout.align.horizontal
}
end)
-- Enable sloppy focus, so that focus follows mouse.
client.connect_signal("mouse::enter", function(c)
if awful.layout.get(c.screen) ~= awful.layout.suit.magnifier
and awful.client.focus.filter(c) then
client.focus = c
end
end)
client.connect_signal("focus", function(c) c.border_color = beautiful.border_focus end)
client.connect_signal("unfocus", function(c) c.border_color = beautiful.border_normal end)
-- }}}
--
--include autorun file
awful.spawn.with_shell("~/.config/awesome/autorun.sh")

View File

@ -10,7 +10,7 @@ local gfs = require("gears.filesystem")
local themes_path =os.getenv("HOME") .. "/.config/awesome/themes/"
local icon_dir = themes_path .. "default/icons/"
local theme = {}
local theme = require("themes/colorless/theme")
theme.font = "Roboto Bold 10"
@ -108,6 +108,8 @@ theme.layout_fairv = themes_path.."default/layouts/fair.svg"
theme.layout_floating = themes_path.."default/layouts/floating.svg"
theme.layout_magnifier = themes_path.."default/layouts/magnifier.svg"
theme.layout_max = themes_path.."default/layouts/max.svg"
theme.layout_grid = themes_path.."default/layouts/grid.svg"
theme.layout_usermap = themes_path.."default/layouts/map.svg"
theme.layout_fullscreen = themes_path.."default/layouts/fullscreen.svg"
theme.layout_tilebottom = themes_path.."default/layouts/tilebottom.svg"
theme.layout_tileleft = themes_path.."default/layouts/tileleft.svg"