Skip to content

Commit

Permalink
Add misc debug messages system
Browse files Browse the repository at this point in the history
  • Loading branch information
NikitaBeloglazov committed Dec 12, 2023
1 parent 9a634ea commit 926ab49
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/clipman/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,15 @@
import time
import shutil
import platform
import traceback
import subprocess

from . import exceptions

def log(message):
if dataclass.debug == True:
print(message)

def check_binary_installed(binary_name):
""" Checks if binary is avalible in this OS """
return shutil.which(binary_name) is not None
Expand Down Expand Up @@ -100,6 +105,7 @@ def __init__(self):
self.os_name = detect_os()
self.engine = None
self.init_called = False
self.debug = False

dataclass = DataClass()

Expand All @@ -124,7 +130,8 @@ def detect_clipboard_engine():
# If call to klipper do not raise errors, everything is OK
return 'org.kde.klipper'
except:
pass
log("klipper init failed:")
log(traceback.format_exc())

if graphical_backend == "x11":
if check_binary_installed("xsel"): # Preffer xsel because is it less laggy and more fresh
Expand Down Expand Up @@ -245,5 +252,7 @@ def call(method, text=None): # pylint: disable=R0911 # too-many-return-statement

def init():
""" Initializes clipman, and detects copy engine for work """
log("init call start")
dataclass.engine = detect_clipboard_engine()
log(f"detected engine: {dataclass.engine}")
dataclass.init_called = True

0 comments on commit 926ab49

Please sign in to comment.