Load more config from host-specific files, add host-config for work DBO, allow using 'fake-screens', various bugfixes
This commit is contained in:
parent
3c72148fcd
commit
8f5e1e282a
5 changed files with 308 additions and 129 deletions
221
kuro/theme.py
221
kuro/theme.py
|
@ -82,14 +82,8 @@ class Kuro(BaseTheme):
|
|||
Match(wm_class='ssh-askpass'), # ssh-askpass
|
||||
Match(title='branchdialog'), # gitk
|
||||
Match(title='pinentry'), # GPG key password entry
|
||||
Match(title='origin.exe', wm_class='Wine'), # Wine Origin game launcher
|
||||
|
||||
# Homebank popups
|
||||
Match(title='Add transaction', wm_class='homebank'),
|
||||
Match(title='Edit transaction', wm_class='homebank'),
|
||||
Match(title='Inherit transaction', wm_class='homebank'),
|
||||
Match(title='Multiple edit transactions', wm_class='homebank'),
|
||||
Match(title='Transaction splits', wm_class='homebank'),
|
||||
# Extra rules from host-specific Config
|
||||
*[Match(**rule) for rule in Config.get('extra_float_rules', [])]
|
||||
]
|
||||
)
|
||||
|
||||
|
@ -106,7 +100,7 @@ class Kuro(BaseTheme):
|
|||
|
||||
def init_keys(self):
|
||||
logger.warning("Initializing keys")
|
||||
return [
|
||||
keys = [
|
||||
# Switch between windows in current stack pane
|
||||
Key([self.mod], "k", lazy.layout.down()),
|
||||
Key([self.mod], "j", lazy.layout.up()),
|
||||
|
@ -151,17 +145,6 @@ class Kuro(BaseTheme):
|
|||
# Lock shortcut
|
||||
Key([self.mod], "l", lazy.spawn(Config.get('lock_command', "i3lock"))),
|
||||
|
||||
# Display modes
|
||||
Key([self.mod], "Prior", lazy.spawn(Config.get('cmd_monitor_mode_3s144', 'true'))),
|
||||
Key([self.mod], "Next", lazy.spawn(Config.get('cmd_monitor_mode_3s60', 'true'))),
|
||||
Key([self.mod], "Home", lazy.spawn(Config.get('cmd_monitor_mode_day', 'true'))),
|
||||
Key([self.mod], "End", lazy.spawn(Config.get('cmd_monitor_mode_night', 'true'))),
|
||||
Key([self.mod], "Insert", lazy.spawn(Config.get('cmd_monitor_mode_alt', 'true'))),
|
||||
|
||||
# Backlight keys
|
||||
Key([], "XF86MonBrightnessUp", lazy.spawn(Config.get('cmd_brightness_up', 'xbacklight -inc 10'))),
|
||||
Key([], "XF86MonBrightnessDown", lazy.spawn(Config.get('cmd_brightness_down', 'xbacklight -dec 10'))),
|
||||
|
||||
# Media keys
|
||||
Key([], "XF86AudioPlay", lazy.spawn(Config.get('cmd_media_play', 'true'))),
|
||||
Key([], "XF86AudioNext", lazy.spawn(Config.get('cmd_media_next', 'true'))),
|
||||
|
@ -218,27 +201,32 @@ class Kuro(BaseTheme):
|
|||
# Spawn a popup, and despawn it after 3 seconds
|
||||
Key([self.mod, "control"], "p", lazy.function(test_popups)),
|
||||
]
|
||||
# Extra keybinds from host-specific Config
|
||||
keys.extend([
|
||||
Key([(self.mod if m == 'mod' else m) for m in key['modifiers']], key['key'], key['action'])
|
||||
for key in Config.get('extra_keys', [])
|
||||
])
|
||||
return keys
|
||||
|
||||
def init_groups(self):
|
||||
logger.warning("Initializing groups")
|
||||
# http://fontawesome.io/cheatsheet
|
||||
groups = [
|
||||
Group(""),
|
||||
Group(""),
|
||||
Group(""),
|
||||
Group(""),
|
||||
Group(""),
|
||||
Group(""),
|
||||
Group(""),
|
||||
Group(""),
|
||||
Group(""),
|
||||
Group("", layout='floating', layouts=[
|
||||
layout.Floating(
|
||||
border_focus="#990000",
|
||||
border_normal="#440000"
|
||||
)
|
||||
])
|
||||
]
|
||||
groups = []
|
||||
|
||||
for group in Config.get('groups', [{'name': '1'}]):
|
||||
if 'layout' in group:
|
||||
if group['layout'] == "floating":
|
||||
groups.append(Group(
|
||||
group['name'],
|
||||
layout="floating",
|
||||
layouts=[
|
||||
layout.Floating(**group.get('options', {}))
|
||||
]
|
||||
))
|
||||
else:
|
||||
logger.warning(f"Unknown group layout for group '{group['name']}': {group['layout']}")
|
||||
else:
|
||||
groups.append(Group(group['name']))
|
||||
return groups
|
||||
|
||||
def init_layouts(self):
|
||||
|
@ -288,8 +276,8 @@ class Kuro(BaseTheme):
|
|||
|
||||
def initialize_colorscheme(self):
|
||||
colors = None
|
||||
if os.path.isfile("/home/kevin/.cache/wal/colors.json"):
|
||||
with open("/home/kevin/.cache/wal/colors.json", 'r') as f:
|
||||
if os.path.isfile(f"{Config.get('homedir', '~')}/.cache/wal/colors.json"):
|
||||
with open(f"{Config.get('homedir', '~')}/.cache/wal/colors.json", 'r') as f:
|
||||
try:
|
||||
colors = json.load(f)['colors']
|
||||
except KeyError:
|
||||
|
@ -305,26 +293,34 @@ class Kuro(BaseTheme):
|
|||
Config.bar_background = colors['color1']
|
||||
|
||||
def reinit_screens(self):
|
||||
# TODO: Move backend check into utils method
|
||||
if qtile.core.name == "x11":
|
||||
self.num_screens = max(1, utils.get_screen_count())
|
||||
if Config.get("use_fake_screens", False):
|
||||
logger.warning(f"Using fake screens!")
|
||||
self.num_screens = Config.get("fake_screen_count", 1)
|
||||
else:
|
||||
self.num_screens = max(1, len(qtile.core.get_screen_info()))
|
||||
self.num_screens = max(1, utils.get_screen_count())
|
||||
logger.warning(f"Detected {self.num_screens} screens.")
|
||||
|
||||
screen_kwargs = Config.get("screen_kwargs", [])
|
||||
|
||||
for x in range(self.num_screens):
|
||||
logger.warning("Reconfiguring bars for screen {}".format(x))
|
||||
logger.warning(f"Reconfiguring bars for screen {x}")
|
||||
|
||||
try:
|
||||
screen = self.screens[x]
|
||||
except IndexError:
|
||||
screen = Screen()
|
||||
try:
|
||||
kwargs = screen_kwargs[x]
|
||||
logger.warning(f"Config for screen {x}: {kwargs}")
|
||||
except IndexError:
|
||||
logger.warning(f"No kwarg config for screen {x}")
|
||||
kwargs = {}
|
||||
screen = Screen(**kwargs)
|
||||
|
||||
if screen.top is None:
|
||||
screen.top = self.build_bar_for_screen(x)
|
||||
topbar = screen.top
|
||||
|
||||
self.screens.append(Screen(top=topbar))
|
||||
self.screens.append(screen)
|
||||
|
||||
def update_keys(self):
|
||||
logger.warning("Updating keys")
|
||||
|
@ -399,60 +395,61 @@ class Kuro(BaseTheme):
|
|||
]
|
||||
|
||||
# Media widget(s)
|
||||
widgets.extend([
|
||||
# An MPRIS widget that shows the media play status as an icon.
|
||||
widget.Mpris2(
|
||||
font=Config.get('font_groupbox', 'Arial'),
|
||||
fontsize=Config.get('fontsize_groupbox', 15),
|
||||
format="",
|
||||
scroll=False,
|
||||
playing_text="",
|
||||
paused_text="",
|
||||
stopped_text="",
|
||||
no_metadata_text="",
|
||||
name=f"media_icon{screen_num}",
|
||||
mouse_callbacks={
|
||||
"Button1": lazy.widget[f"media_icon{screen_num}"].play_pause(),
|
||||
"Button3": lazy.widget[f"media_icon{screen_num}"].next(),
|
||||
"Button4": lambda: None,
|
||||
"Button5": lambda: None,
|
||||
}
|
||||
),
|
||||
# An MPRIS widget that shows the currently playing song information in a nice format.
|
||||
widget.Mpris2(
|
||||
font=Config.get('font_topbar', 'Arial'),
|
||||
fontsize=Config.get('fontsize_topbar', 15),
|
||||
format="<b>{xesam:title}</b> - {xesam:artist} - <i>{xesam:album}</i>",
|
||||
scroll=True,
|
||||
width=300, # Maximum width before widget starts scrolling
|
||||
playing_text="{track}",
|
||||
paused_text="{track}",
|
||||
stopped_text="",
|
||||
no_metadata_text="No metadata available",
|
||||
name=f"media_text{screen_num}",
|
||||
mouse_callbacks={
|
||||
"Button1": lazy.widget[f"media_icon{screen_num}"].play_pause(),
|
||||
"Button3": lazy.widget[f"media_icon{screen_num}"].next(),
|
||||
"Button4": lambda: None,
|
||||
"Button5": lambda: None,
|
||||
}
|
||||
),
|
||||
# An MPRIS widget masquerading as a text widget, that only shows "|" when media is playing or paused.
|
||||
widget.Mpris2(
|
||||
fontsize=14,
|
||||
format="",
|
||||
scroll=False,
|
||||
playing_text="|",
|
||||
paused_text="|",
|
||||
stopped_text="",
|
||||
no_metadata_text="",
|
||||
mouse_callbacks={
|
||||
"Button1": lambda: None,
|
||||
"Button4": lambda: None,
|
||||
"Button5": lambda: None,
|
||||
}
|
||||
)
|
||||
])
|
||||
if Config.get('show_media_widget', False):
|
||||
widgets.extend([
|
||||
# An MPRIS widget that shows the media play status as an icon.
|
||||
widget.Mpris2(
|
||||
font=Config.get('font_groupbox', 'Arial'),
|
||||
fontsize=Config.get('fontsize_groupbox', 15),
|
||||
format="",
|
||||
scroll=False,
|
||||
playing_text="",
|
||||
paused_text="",
|
||||
stopped_text="",
|
||||
no_metadata_text="",
|
||||
name=f"media_icon{screen_num}",
|
||||
mouse_callbacks={
|
||||
"Button1": lazy.widget[f"media_icon{screen_num}"].play_pause(),
|
||||
"Button3": lazy.widget[f"media_icon{screen_num}"].next(),
|
||||
"Button4": lambda: None,
|
||||
"Button5": lambda: None,
|
||||
}
|
||||
),
|
||||
# An MPRIS widget that shows the currently playing song information in a nice format.
|
||||
widget.Mpris2(
|
||||
font=Config.get('font_topbar', 'Arial'),
|
||||
fontsize=Config.get('fontsize_topbar', 15),
|
||||
format="<b>{xesam:title}</b> - {xesam:artist} - <i>{xesam:album}</i>",
|
||||
scroll=True,
|
||||
width=300, # Maximum width before widget starts scrolling
|
||||
playing_text="{track}",
|
||||
paused_text="{track}",
|
||||
stopped_text="",
|
||||
no_metadata_text="No metadata available",
|
||||
name=f"media_text{screen_num}",
|
||||
mouse_callbacks={
|
||||
"Button1": lazy.widget[f"media_icon{screen_num}"].play_pause(),
|
||||
"Button3": lazy.widget[f"media_icon{screen_num}"].next(),
|
||||
"Button4": lambda: None,
|
||||
"Button5": lambda: None,
|
||||
}
|
||||
),
|
||||
# An MPRIS widget masquerading as a text widget, that only shows "|" when media is playing or paused.
|
||||
widget.Mpris2(
|
||||
fontsize=14,
|
||||
format="",
|
||||
scroll=False,
|
||||
playing_text="|",
|
||||
paused_text="|",
|
||||
stopped_text="",
|
||||
no_metadata_text="",
|
||||
mouse_callbacks={
|
||||
"Button1": lambda: None,
|
||||
"Button4": lambda: None,
|
||||
"Button5": lambda: None,
|
||||
}
|
||||
)
|
||||
])
|
||||
|
||||
# Sensor widgets
|
||||
sensor_widgets = []
|
||||
|
@ -583,12 +580,13 @@ class Kuro(BaseTheme):
|
|||
|
||||
logger.warning("Restoring wallpaper...")
|
||||
if self.current_wallpaper:
|
||||
p = utils.execute_once(["wallust", "run", "{}".format(self.current_wallpaper)])
|
||||
p.wait()
|
||||
p = utils.execute_once([*Config.get('cmd_wal', ['wallust', 'run']), "{}".format(self.current_wallpaper)])
|
||||
if p:
|
||||
p.wait()
|
||||
else:
|
||||
wallpaper = None
|
||||
if os.path.isfile("/home/kevin/.cache/wal/colors.json"):
|
||||
with open("/home/kevin/.cache/wal/colors.json", 'r') as f:
|
||||
if os.path.isfile(f"{Config.get('homedir', '~')}/.cache/wal/colors.json"):
|
||||
with open(f"{Config.get('homedir', '~')}/.cache/wal/colors.json", 'r') as f:
|
||||
try:
|
||||
wallpaper = json.load(f)['wallpaper']
|
||||
except KeyError:
|
||||
|
@ -741,7 +739,8 @@ class Kuro(BaseTheme):
|
|||
def set_wallpaper(self, filename):
|
||||
if qtile.core.name == "x11":
|
||||
p = utils.execute_once(f"{Config.get('x11_wallpaper_config_command', 'wal-nitrogen-noupdate')} {filename}")
|
||||
p.wait()
|
||||
if p:
|
||||
p.wait()
|
||||
else:
|
||||
# Wayland can set wallpaper in qtile directly per screen
|
||||
for screen_i, screen in enumerate(qtile.screens):
|
||||
|
@ -760,12 +759,13 @@ class Kuro(BaseTheme):
|
|||
def update_colorscheme(self, *args, **kwargs):
|
||||
if self.current_wallpaper:
|
||||
logger.warning(f"Updating wal colors for wallpaper {self.current_wallpaper}")
|
||||
p = utils.execute_once(["wallust", "run", "{}".format(self.current_wallpaper)])
|
||||
p.wait()
|
||||
p = utils.execute_once([*Config.get('cmd_wal', ['wallust', 'run']), "{}".format(self.current_wallpaper)])
|
||||
if p:
|
||||
p.wait()
|
||||
|
||||
colors = None
|
||||
if os.path.isfile("/home/kevin/.cache/wal/colors.json"):
|
||||
with open("/home/kevin/.cache/wal/colors.json", 'r') as f:
|
||||
if os.path.isfile(f"{Config.get('homedir', '~')}/.cache/wal/colors.json"):
|
||||
with open(f"{Config.get('homedir', '~')}/.cache/wal/colors.json", 'r') as f:
|
||||
try:
|
||||
colors = json.load(f)['colors']
|
||||
except KeyError:
|
||||
|
@ -851,7 +851,8 @@ class Kuro(BaseTheme):
|
|||
try:
|
||||
logger.warning(f"Calling 'pywalfox update'...")
|
||||
p = utils.execute(["pywalfox", "update"])
|
||||
p.wait()
|
||||
if p:
|
||||
p.wait()
|
||||
except subprocess.SubprocessError as e:
|
||||
logger.error(f"Error running 'pywalfox update': {e}")
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue