import os
import sys
import subprocess

from libqtile import layout, bar, widget, hook
from libqtile.config import Key, Drag, Click, Group, Screen, ScratchPad, DropDown
from libqtile.command import lazy

sys.path.append("/home/paul/.config/qtile")

from defines import hotkey_file
from Keys import keys
from Groups import groups
from Layouts import layouts, floating_layout
from Bars import top_bar, left_bar, main_bar, widget_defaults, extension_defaults
from Screens import screens

#region Hooks
@hook.subscribe.startup_once
def autostart():
    home = os.path.expanduser('~/.config/qtile/autostart.sh')
    subprocess.call([home])

#region miscelanious
dgroups_key_binder = None
dgroups_app_rules = []  # type: List
main = None  # WARNING: this is deprecated and will be removed soon
follow_mouse_focus = True
bring_front_click = True
cursor_warp = False
auto_fullscreen = True
focus_on_window_activation = "smart"

#region Hotkey_Wallpaper

#create hotkey textfile
# if os.path.isfile(hotkey_file):
    # os.remove(hotkey_file)
# with open(hotkey_file,'w') as file: 
    # for key in keys:
        # if not str(key.key).startswith("XF86"):
            # modifiers=""
            # for modifier in key.modifiers:
                # modifiers += '{:^7}'.format(
                    # str(modifier).replace("mod1","Alt").replace("mod4","Super").replace("shift","Shift").replace("control","Ctrl")
                    # ) + "+"
            # file.write('{:30}'.format(modifiers+' '+str(key.key).upper())+"=>     "+key.desc)
            # file.write('\n')
#endregion

# XXX: Gasp! We're lying here. In fact, nobody really uses or cares about this
# string besides java UI toolkits; you can see several discussions on the
# mailing lists, GitHub issues, and other WM documentation that suggest setting
# this string if your java app doesn't work correctly. We may as well just lie
# and say that we're a working one by default.
#
# We choose LG3D to maximize irony: it is a 3D non-reparenting WM written in
# java that happens to be on java's whitelist.
wmname = "LG3D"
#endregion
