mirror of
https://github.com/aclist/dztui.git
synced 2026-10-31 07:02:50 +01:00
chore: abstraction
This commit is contained in:
1 parent
31d289048f
commit
922ff7b3b2
1 file changed
+23
-13
+23
-13
@@ -42,7 +42,23 @@ parser.add_argument("-u", "--uninstall", action="store_true", help=flags.uninsta
|
|||||||
parser.add_argument("-d", "--developers", action="store_true", help=flags.developers)
|
parser.add_argument("-d", "--developers", action="store_true", help=flags.developers)
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
# TODO: profile load time
|
# TODO: profile load time
|
||||||
|
def make_parents(path: "Path") -> None:
|
||||||
|
path.parent.mkdir(parents=True, exist_ok=True)
|
||||||
|
|
||||||
|
def uninstall() -> None:
|
||||||
|
# TODO: uninstall data files (-u)
|
||||||
|
# -u removes state, log, freedesktop
|
||||||
|
# XDG_SHARE_HOME/dzgui
|
||||||
|
# XDG_STATE_HOME/dzgui
|
||||||
|
# XDG_DATA_HOME/dzgui
|
||||||
|
pass
|
||||||
|
|
||||||
def main() -> None:
|
def main() -> None:
|
||||||
lock = lock_acquire() # noqa
|
lock = lock_acquire() # noqa
|
||||||
|
|
||||||
@@ -50,11 +66,9 @@ def main() -> None:
|
|||||||
print(get_version())
|
print(get_version())
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
# TODO: uninstall data files (-u)
|
if args.uninstall is True:
|
||||||
# -u removes state, log, freedesktop
|
uninstall()
|
||||||
# XDG_SHARE_HOME/dzgui
|
sys.exit(0)
|
||||||
# XDG_STATE_HOME/dzgui
|
|
||||||
# XDG_DATA_HOME/dzgui
|
|
||||||
|
|
||||||
version = get_version()
|
version = get_version()
|
||||||
set_locale()
|
set_locale()
|
||||||
@@ -62,11 +76,11 @@ def main() -> None:
|
|||||||
# NOTE: consider aborting this check if steam deck
|
# NOTE: consider aborting this check if steam deck
|
||||||
xdg_paths = get_xdg_paths()
|
xdg_paths = get_xdg_paths()
|
||||||
XDG = parse_filepaths(xdg_paths)
|
XDG = parse_filepaths(xdg_paths)
|
||||||
# TODO: ensure state path is created
|
|
||||||
|
|
||||||
# NOTE: required for logs to be written
|
if XDG.resolution.parent.is_dir() is False:
|
||||||
|
make_parents(XDG.resolution)
|
||||||
if XDG.debug.is_file() is False:
|
if XDG.debug.is_file() is False:
|
||||||
XDG.debug.parent.mkdir(parents=True, exist_ok=True)
|
make_parents(XDG.debug)
|
||||||
|
|
||||||
if has_new_config(XDG.config) is False:
|
if has_new_config(XDG.config) is False:
|
||||||
migrate_legacy_conf(XDG.config)
|
migrate_legacy_conf(XDG.config)
|
||||||
@@ -78,17 +92,13 @@ def main() -> None:
|
|||||||
with open(XDG.debug, "w") as f:
|
with open(XDG.debug, "w") as f:
|
||||||
f.truncate(0)
|
f.truncate(0)
|
||||||
|
|
||||||
|
|
||||||
_is_steam_deck = is_steam_deck()
|
_is_steam_deck = is_steam_deck()
|
||||||
_is_game_mode = False
|
_is_game_mode = is_game_mode() if _is_steam_deck else False
|
||||||
if _is_steam_deck:
|
|
||||||
_is_game_mode = is_game_mode()
|
|
||||||
if _is_game_mode:
|
if _is_game_mode:
|
||||||
# NOTE: this may no longer be necessary on newer versions of SteamOS
|
# NOTE: this may no longer be necessary on newer versions of SteamOS
|
||||||
del os.environ["GTK_IM_MODULE"]
|
del os.environ["GTK_IM_MODULE"]
|
||||||
|
|
||||||
# TODO: test spamming timeout
|
# TODO: test spamming timeout
|
||||||
allow = False
|
|
||||||
allow = allow_updates(ALLOW_UPDATES)
|
allow = allow_updates(ALLOW_UPDATES)
|
||||||
if allow is True:
|
if allow is True:
|
||||||
check_updates(version)
|
check_updates(version)
|
||||||
|
|||||||
Reference in new issue
Block a user