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") function powermenu.suspend() awful.spawn("dbus-send --system --print-reply --dest=org.freedesktop.login1 /org/freedesktop/login1 org.freedesktop.login1.Manager.Suspend boolean:true") end function powermenu.poweroff() awful.spawn("dbus-send --system --print-reply --dest=org.freedesktop.login1 /org/freedesktop/login1 org.freedesktop.login1.Manager.PowerOff boolean:true") end -- {{{ 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 = "Mod4" terminal = "xfce4-terminal" 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 awful.screen.connect_for_each_screen(function(s) s.powermenu = powermenu.new(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() awful.screen.focused().powermenu:toggle() end, "show power menu", "launcher") global_key({}, "XF86PowerOff", function() awful.screen.focused().powermenu:toggle() end, "show power menu", "launcher") global_key({modkey}, "Space", function() awful.spawn(launcher) end, "Show launcher", "launcher") client_key({modkey,"Mod1"},"q",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 } }, -- Make terminals and mpv fill the whole screen rather than leave small gaps. { rule_any = { class = {"xfce4-terminal", "Xfce4-terminal", "mpv"}, }, properties = { size_hints_honor = false } }, } -- }}} -- {{{ 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) -- }}} -- timer to run Lua garbage collection -- may not be necessary, but just in case gears.timer.start_new(60, function() collectgarbage("step",1024) return true end) -- run autostart script, either from home folder or system copy if gears.filesystem.file_readable(string.format("%s/.config/awesome-mobile/autostart.sh",os.getenv("HOME"))) then awful.spawn(gears.filesystem.file_readable(string.format("%s/.config/awesome-mobile/autostart.sh",os.getenv("HOME")))) else awful.spawn(gears.filesystem.get_configuration_dir().."/autostart.sh") end