awesome-mobile/rc.lua

181 lines
5.1 KiB
Lua

local gears = require("gears")
local awful = require("awful")
awful.rules = require("awful.rules")
require("awful.autofocus")
local beautiful = require("beautiful")
local wibox = require("wibox")
local naughty = require("naughty")
local vkbd = require("vkbd")
vkbd.spacing = 1
local switcherpopup = require("awesome-switcherpopup")
local powermenu = require("awesome-powermenu")
local launcherpopup = require("awesome-launcherpopup")
local longpress = require("awesome-longpress")
local navbar = require("awesome-navbar")
if not beautiful.init(string.format("%s/.config/awesome-mobile/theme.lua",os.getenv("HOME"))) then
beautiful.init(gears.filesystem.get_configuration_dir().."/theme.lua")
end
vkbd.init("ansi")
-- {{{ 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
-- 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
-- }}}
--- Naughty Configuration
naughty.config.defaults.position = "top_middle"
for _, lvl in ipairs {"low", "normal", "critical"} do
naughty.config.presets[lvl].width = 700
end
modkey = "Control"
terminal = "kgx"
launcher = "xfce4-appfinder"
-- {{{ Layout
-- Table of layouts to cover with awful.layout.inc, order matters.
local 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.spiral,
-- awful.layout.suit.spiral.dwindle,
awful.layout.suit.max
-- awful.layout.suit.max.fullscreen,
-- awful.layout.suit.magnifier,
-- awful.layout.suit.floating,
}
-- }}}
-- {{{ Tags
awful.screen.connect_for_each_screen(function(s)
awful.tag({"1"}, s, layouts[1])
end)
local function nextTagName(s)
return tostring(#s.tags+1)
end
-- }}}
-- {{{ Widgets and etc
-- Power menu for
powermenuPopup = powermenu.new()
awful.screen.connect_for_each_screen(function(s)
s.navbar = navbar.new(s)
gears.wallpaper.maximized(beautiful.wallpaper,s,false)
end)
-- }}}
-- {{{ Key bindings
globalkeys = gears.table.join(awful.key({modkey, "Control", "Shift"}, "r",
awesome.restart, {
description = "restart awesome",
group = "awesome"
}))
local function global_key(mods, key, cb, opt_desc, opt_group)
local opt_data = {}
if opt_desc then opt_data.description = opt_desc end
if opt_group then opt_data.group = opt_group end
globalkeys = gears.table.join(globalkeys, awful.key(mods, key, cb, opt_data))
end
local function client_key(mods, key, cb, opt_desc, opt_group)
local opt_data = {}
if opt_desc then opt_data.description = opt_desc end
if opt_group then opt_data.group = opt_group end
clientkeys = gears.table.join(clientkeys, awful.key(mods, key, cb, opt_data))
end
global_key({modkey}, "Return", function() awful.spawn(terminal) end, "open a terminal", "launcher")
global_key({modkey}, "p", function() powermenuPopup:toggle() end, "show power menu", "launcher")
global_key({}, "XF86PowerOff", function() powermenuPopup:toggle() end, "show power menu", "launcher")
global_key({modkey}, "Space", function() awful.spawn(launcher) end, "Show launcher", "launcher")
client_key({modkey,"Alt"},"c",function(c) c:kill() end, "close application","client")
root.keys(globalkeys)
-- }}}
-- {{{ Rules
awful.rules.rules = {
-- All clients will match this rule.
{
rule = {},
properties = {
keys = clientkeys,
border_width = 0,
focus = awful.client.focus.filter,
raise = true,
placement = awful.placement.no_overlap + awful.placement.no_offscreen
}
}
}
-- }}}
-- {{{ Signals
-- Signal function to execute when a new client appears.
client.connect_signal("manage", function(c, startup)
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 c.size_hints.user_position and not c.size_hints.program_position then
awful.placement.no_overlap(c)
awful.placement.no_offscreen(c)
end
end
if not next(c.icon_sizes) then
c.icon = gears.surface(gears.filesystem.get_configuration_dir().."/application-x-executable.svg")._native
end
end)
-- }}}
client.connect_signal("mouse::enter", function(c)
c:emit_signal("request::activate", "mouse_enter", {raise = false})
end)
awful.spawn("gnome-calls -d")
awful.spawn("chatty -D")
awful.spawn("nm-applet")
awful.spawn("xfce4-power-manager")