Skip to content

Commit

Permalink
feat(qtile): added minecraft to qtile groups
Browse files Browse the repository at this point in the history
  • Loading branch information
Wittano committed Feb 15, 2024
1 parent 17927ab commit 7c6f229
Showing 1 changed file with 27 additions and 33 deletions.
60 changes: 27 additions & 33 deletions dotfiles/qtile/groups.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from itertools import chain
from typing import List, Tuple, Union

from libqtile.config import Match, Group
from libqtile.config import Group, Match

_default_groups = [
Group(name="1", label="\uebb4", layout="max"),
Expand All @@ -16,10 +16,7 @@


class _WindowMatch:

def __init__(self,
group: Union[str, int],
match_rule: Match):
def __init__(self, group: Union[str, int], match_rule: Match):
self.group = group
self.match_rule = match_rule

Expand All @@ -41,7 +38,9 @@ def __init__(self,
r"^([Mm]inecraft)(.+)",
r"steam_app*",
r"[Ss]team*",
r"[Mm]ono"
r"[Mm]ono",
r"[Mm]inecraft*",
r"[Pp]rism[lL]auncher",
]

_web_browsers: List[str] = [
Expand All @@ -58,19 +57,12 @@ def __init__(self,
"Code",
"jetbrains-*",
"code-oss",
r"(vsc)|(VSC)odium"
r"(vsc)|(VSC)odium",
]

_terminals: List[str] = [
"kitty",
r"[tT]erminator"
]
_terminals: List[str] = ["kitty", r"[tT]erminator"]

_science_staff: List[str] = [
"Boincmgr",
"Virt-manager",
"VirtualBox Manager"
]
_science_staff: List[str] = ["Boincmgr", "Virt-manager", "VirtualBox Manager"]

_music_staff: List[str] = [
"Qmmp",
Expand All @@ -79,17 +71,9 @@ def __init__(self,
"Rhythmbox",
]

_chat_staff: List[str] = [
"discord",
r"[sS]ignal*"
"telegram-desktop"
"TelegramDesktop"
]
_chat_staff: List[str] = ["discord", r"[sS]ignal*" "telegram-desktop" "TelegramDesktop"]

_doc_staff: List[str] = [
"obsidian",
"Evince"
]
_doc_staff: List[str] = ["obsidian", "Evince"]

_matches: List[_WindowMatch] = [
_WindowMatch(group="5", match_rule=Match(wm_class="discord")),
Expand Down Expand Up @@ -124,8 +108,12 @@ def _get_wm_name(wm_name: str) -> Union[str, re.Pattern]:


def _map_wm_names(group: Group, wm_names_list: List[str]):
return map(lambda wm_name: _WindowMatch(group=group.name,
match_rule=Match(wm_class=_get_wm_name(wm_name))), wm_names_list)
return map(
lambda wm_name: _WindowMatch(
group=group.name, match_rule=Match(wm_class=_get_wm_name(wm_name))
),
wm_names_list,
)


def _get_windows_matches() -> List[_WindowMatch]:
Expand All @@ -142,18 +130,24 @@ def _get_windows_matches() -> List[_WindowMatch]:
(sys_group, _science_staff),
(doc_group, _music_staff),
(doc_group, _doc_staff),
(chat_group, _chat_staff)
(chat_group, _chat_staff),
]

window_matches_list = map(lambda group_match: _map_wm_names(group_match[0], group_match[1]), _group_matches)
window_matches_list = map(
lambda group_match: _map_wm_names(group_match[0], group_match[1]),
_group_matches,
)
flatten_group_matches: List[_WindowMatch] = list(chain(*window_matches_list))

return _matches + flatten_group_matches


def _get_matches_list(group_name: str) -> List[Match]:
windows_matches_list: List[_WindowMatch] = _get_windows_matches()
filtered_windows_matches_list: filter[_WindowMatch] = filter(lambda window_match: window_match.group == group_name,
windows_matches_list)
filtered_windows_matches_list: filter[_WindowMatch] = filter(
lambda window_match: window_match.group == group_name, windows_matches_list
)

return list(map(lambda window_match: window_match.match_rule, filtered_windows_matches_list))
return list(
map(lambda window_match: window_match.match_rule, filtered_windows_matches_list)
)

0 comments on commit 7c6f229

Please sign in to comment.