More stuff

This commit is contained in:
Daan Vanoverloop 2019-08-26 15:16:50 +02:00
parent a86e342735
commit 7ec776db74
5 changed files with 247 additions and 22 deletions

View File

@ -0,0 +1,39 @@
[autohidewibox]
# Select your awesome version
# Possible values: 3, 4
awesomeVersion=4
# A comma-separated list of keys.
# Some suggestions:
# 133 - Meta-L
# 134 - Meta-R
# 37 - Ctrl-L
# 105 - Ctrl-R
# 66 - CapsLock
superKeys=133,134
# The show/hide behavior. Possible values:
# 'transient': The wibox is only shown while a super key is pressed.
# 'toggle': Pressing and releasing a super key (press and release) toggles
# the wibox visibility.
# Default = transient.
mode=transient
# The name of one or more (comma separated)
# wiboxes which to autohide.
wiboxname=mywibox
# Delay execution in ms
delayShow=600
delayHide=0
# Custom commands to send to awesome
# Use this to call custom-defined event functions in your awesome config
# (Note: You can leave 'wiboxname' above empty, or remove it completely)
customhide=stopgaps()
customshow=startgaps()
# Used for debug/development purposes. Prints extra bits information.
# Possible values: 0, 1
debug=0

171
.config/awesome/autohidewibox.py Executable file
View File

@ -0,0 +1,171 @@
#!/usr/bin/python3
import subprocess
import re
import configparser
import os.path as path
import sys
import threading
MODE_TRANSIENT = "transient"
MODE_TOGGLE = "toggle"
config = configparser.ConfigParser()
try:
userconf = path.join(path.expanduser("~"), ".config/autohidewibox.conf")
if len(sys.argv)>1 and path.isfile(sys.argv[1]):
config.read(sys.argv[1])
elif path.isfile(userconf):
config.read(userconf)
else:
config.read("/etc/autohidewibox.conf")
except configparser.MissingSectionHeaderError:
pass
awesomeVersion = config.get( "autohidewibox", "awesomeVersion", fallback=4)
superKeys = config.get( "autohidewibox", "superKeys", fallback="133,134").split(",")
wiboxes = config.get( "autohidewibox", "wiboxname", fallback="mywibox").split(",")
customhide = config.get( "autohidewibox", "customhide", fallback=None)
customshow = config.get( "autohidewibox", "customshow", fallback=None)
delayShow = config.getfloat( "autohidewibox", "delayShow", fallback=0)
delayHide = config.getfloat( "autohidewibox", "delayHide", fallback=0)
mode = config.get( "autohidewibox", "mode", fallback=MODE_TRANSIENT)
debug = config.getboolean("autohidewibox", "debug", fallback=False)
# (remove the following line if your wibox variables have strange characters)
wiboxes = [ w for w in wiboxes if re.match("^[a-zA-Z_][a-zA-Z0-9_]*$", w) ]
#python>=3.4: wiboxes = [ w for w in wiboxes if re.fullmatch("[a-zA-Z_][a-zA-Z0-9_]*", w) ]
delay = {True: delayShow, False: delayHide}
delayThread = None
wiboxIsCurrentlyVisible = False
waitingFor = False
nonSuperKeyWasPressed = False
cancel = threading.Event()
shPath = ""
shPotentialPaths = ["/usr/bin/sh", "/bin/sh"]
for p in shPotentialPaths:
if path.exists(p):
shPath = p
break
if shPath == "":
print("Can't find sh in any of: " + ",".join(shPotentialPaths), file=sys.stderr)
sys.exit(1)
hideCommand3 = "for k,v in pairs({wibox}) do v.visible = {state} end"
hideCommand4 = "for s in screen do s.{wibox}.visible = {state} end"
try:
hideCommand = hideCommand4 if int(awesomeVersion) >= 4 else hideCommand3
except ValueError:
hideCommand = hideCommand4
def _debug(*args):
if debug:
print(*args)
def setWiboxState(state=True, immediate=False):
global delayThread, waitingFor, cancel, wiboxIsCurrentlyShown
wiboxIsCurrentlyShown = state
dbgPstate = "show" if state else "hide"
if delay[not state] > 0:
_debug(dbgPstate, "delay other")
if type(delayThread) == threading.Thread and delayThread.is_alive():
# two consecutive opposing events cancel out. second event should not be called
_debug(dbgPstate, "delay other, thread alive -> cancel")
cancel.set()
return
if delay[state] > 0 and not immediate:
_debug(dbgPstate + " delay same")
if not (type(delayThread) == threading.Thread and delayThread.is_alive()):
_debug(dbgPstate, "delay same, thread dead -> start wait")
waitingFor = state
cancel.clear()
delayThread = threading.Thread(group=None, target=waitDelay, kwargs={"state": state})
delayThread.daemon = True
delayThread.start()
# a second event setting the same state is silently discarded
return
_debug("state:", dbgPstate)
customcmd = customshow if state else customhide
if customcmd:
subprocess.call(
shPath + " " +
"-c \"echo '" +
customcmd +
"' | awesome-client\"",
shell=True)
for wibox in wiboxes:
subprocess.call(
shPath + " " +
"-c \"echo '" +
hideCommand.format(wibox=wibox, state="true" if state else "false") +
"' | awesome-client\"",
shell=True)
def waitDelay(state=True):
if not cancel.wait(delay[state]/1000):
setWiboxState(state=state, immediate=True)
try:
setWiboxState(False)
proc = subprocess.Popen(['xinput', '--test-xi2', '--root', '3'], stdout=subprocess.PIPE)
field = None
keystate = None
for line in proc.stdout:
l = line.decode("utf-8").strip()
eventmatch = re.match("EVENT type (\\d+) \\(.+\\)", l)
detailmatch = re.match("detail: (\\d+)", l)
if eventmatch:
_debug(eventmatch)
try:
field = "event"
keystate = eventmatch.group(1)
_debug("found event, waiting for detail...")
except IndexError:
field = None
keystate = None
if (field is "event") and detailmatch:
_debug(detailmatch)
try:
if detailmatch.group(1) in superKeys:
_debug("is a super key")
if keystate == "13": # press
nonSuperKeyWasPressed = False
if mode == MODE_TRANSIENT:
_debug("showing wibox")
setWiboxState(True)
if keystate == "14": # release
if mode == MODE_TRANSIENT:
_debug("hiding wibox")
setWiboxState(False)
# Avoid toggling the wibox when a super key is used in conjunction
# with another key.
elif mode == MODE_TOGGLE and not nonSuperKeyWasPressed:
_debug("toggling wibox")
setWiboxState(not wiboxIsCurrentlyShown)
nonSuperKeyWasPressed = False
else:
nonSuperKeyWasPressed = True
except IndexError:
_debug("Couldn't parse keystate number.")
pass
finally:
field = None
keystate = None
except KeyboardInterrupt:
pass
finally:
setWiboxState(True, True)
# print("Shutting down")

View File

@ -8,3 +8,6 @@ function run {
}
. ~/.config/compton/launch.sh
run ~/.config/awesome/autohidewibox.py ~/.config/awesome/autohidewibox.conf
run ~/setbg.sh
run dunst

View File

@ -232,8 +232,22 @@ root.buttons(gears.table.join(
))
-- }}}
function startgaps ()
beautiful.useless_gap = 10
end
function stopgaps ()
beautiful.useless_gap = 0
end
key.connect_signal("press", function(k)
print("hello")
end)
-- {{{ Key bindings
globalkeys = gears.table.join(
awful.key({ modkey, }, "", startgaps, stopgaps),
awful.key({ modkey, }, "s", hotkeys_popup.show_help,
{description="show help", group="awesome"}),
awful.key({ modkey, }, "Left", awful.tag.viewprev,
@ -332,7 +346,23 @@ globalkeys = gears.table.join(
awful.key({ modkey }, "p", function() menubar.show() end,
{description = "show the menubar", group = "launcher"}),
awful.key({ modkey }, "d", function() awful.spawn("rofi -show run") end,
{description = "launch rofi", group = "launcher"})
{description = "launch rofi", group = "launcher"}),
awful.key({ modkey, "Shift" }, "m",
function (c)
awful.spawn("dmenu_script minecraft.sh")
end ,
{description = "Play Minecraft"}),
awful.key({ modkey, "Shift" }, "f",
function (c)
awful.spawn("dmenu_script factorio.sh")
end ,
{description = "Play Factorio"}),
awful.key({ modkey, "Shift" }, "g",
function (c)
awful.spawn("dmenu_script lutris.sh")
end ,
{description = "Play a Game"})
)
clientkeys = gears.table.join(
@ -358,25 +388,7 @@ clientkeys = gears.table.join(
-- minimized, since minimized clients can't have the focus.
c.minimized = true
end ,
{description = "minimize", group = "client"}),
awful.key({ modkey, }, "m",
function (c)
c.maximized = not c.maximized
c:raise()
end ,
{description = "(un)maximize", group = "client"}),
awful.key({ modkey, "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",
function (c)
c.maximized_horizontal = not c.maximized_horizontal
c:raise()
end ,
{description = "(un)maximize horizontally", group = "client"})
{description = "minimize", group = "client"})
)
-- Bind all key numbers to tags.

View File

@ -11,7 +11,7 @@ local themes_path = gfs.get_themes_dir()
local theme = {}
theme.font = "sans 8"
theme.font = "sans 10"
theme.bg_normal = "#222222"
theme.bg_focus = "#535d6c"
@ -25,7 +25,7 @@ theme.fg_urgent = "#ffffff"
theme.fg_minimize = "#ffffff"
theme.useless_gap = dpi(0)
theme.border_width = dpi(1)
theme.border_width = dpi(0)
theme.border_normal = "#000000"
theme.border_focus = "#535d6c"
theme.border_marked = "#91231c"