forked from abdallah-hader/typing_settings
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use sound_lib/bass for playback. This majorly improves responsiveness…
… and sounds no longer interrupt each other. In addition, adds volume slider.
- Loading branch information
Bryn
committed
Jul 17, 2023
1 parent
f10b7c8
commit 61ac0d7
Showing
165 changed files
with
5,634 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file added
BIN
+8.41 KB
globalPlugins/typing_settings/__pycache__/__init__.cpython-37.opt-1.pyc
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
from .libloader import * | ||
|
||
__version__ = 0.21 | ||
__author__ = "Christopher Toth" | ||
__author_email__ = "[email protected]" | ||
__doc__ = """ | ||
Quickly and easily load shared libraries from various platforms. Also includes a libloader.com module for loading com modules on Windows. | ||
""" |
Binary file added
BIN
+485 Bytes
globalPlugins/typing_settings/libloader/__pycache__/__init__.cpython-37.pyc
Binary file not shown.
Binary file added
BIN
+431 Bytes
globalPlugins/typing_settings/libloader/__pycache__/__init__.cpython-39.pyc
Binary file not shown.
Binary file added
BIN
+700 Bytes
globalPlugins/typing_settings/libloader/__pycache__/com.cpython-39.pyc
Binary file not shown.
Binary file added
BIN
+1.75 KB
globalPlugins/typing_settings/libloader/__pycache__/libloader.cpython-37.pyc
Binary file not shown.
Binary file added
BIN
+1.71 KB
globalPlugins/typing_settings/libloader/__pycache__/libloader.cpython-39.pyc
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
from pywintypes import com_error | ||
from win32com.client import gencache | ||
|
||
|
||
def prepare_gencache(): | ||
gencache.is_readonly = False | ||
gencache.GetGeneratePath() | ||
|
||
|
||
def load_com(*names): | ||
if gencache.is_readonly: | ||
prepare_gencache() | ||
result = None | ||
for name in names: | ||
try: | ||
result = gencache.EnsureDispatch(name) | ||
break | ||
except com_error: | ||
continue | ||
if result is None: | ||
raise com_error("Unable to load any of the provided com objects.") | ||
return result |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import ctypes | ||
import collections | ||
import platform | ||
import os | ||
import sys | ||
|
||
|
||
TYPES = { | ||
"Linux": { | ||
"loader": ctypes.CDLL, | ||
"functype": ctypes.CFUNCTYPE, | ||
"prefix": "lib", | ||
"extension": ".so", | ||
}, | ||
"Darwin": { | ||
"loader": ctypes.CDLL, | ||
"functype": ctypes.CFUNCTYPE, | ||
"prefix": "lib", | ||
"extension": ".dylib", | ||
}, | ||
} | ||
if platform.system() == "Windows": | ||
TYPES["Windows"] = { | ||
"loader": ctypes.WinDLL, | ||
"functype": ctypes.WINFUNCTYPE, | ||
"prefix": "", | ||
"extension": ".dll", | ||
} | ||
|
||
|
||
class LibraryLoadError(OSError): | ||
pass | ||
|
||
|
||
def load_library(library, x86_path=".", x64_path=".", *args, **kwargs): | ||
lib = find_library_path(library, x86_path=x86_path, x64_path=x64_path) | ||
loaded = _do_load(lib, *args, **kwargs) | ||
if loaded is not None: | ||
return loaded | ||
raise LibraryLoadError( | ||
"unable to load %r. Provided library path: %r" % (library, path) | ||
) | ||
|
||
|
||
def _do_load(file, *args, **kwargs): | ||
loader = TYPES[platform.system()]["loader"] | ||
return loader(file, *args, **kwargs) | ||
|
||
|
||
def find_library_path(libname, x86_path=".", x64_path="."): | ||
libname = "%s%s" % (TYPES[platform.system()]["prefix"], libname) | ||
if platform.architecture()[0] == "64bit": | ||
path = os.path.join(x64_path, libname) | ||
else: | ||
path = os.path.join(x86_path, libname) | ||
ext = get_library_extension() | ||
path = "%s%s" % (path, ext) | ||
return os.path.abspath(path) | ||
|
||
|
||
def get_functype(): | ||
return TYPES[platform.system()]["functype"] | ||
|
||
|
||
def get_library_extension(): | ||
return TYPES[platform.system()]["extension"] |
Empty file.
Binary file added
BIN
+201 Bytes
globalPlugins/typing_settings/platform_utils/__pycache__/__init__.cpython-37.pyc
Binary file not shown.
Binary file added
BIN
+147 Bytes
globalPlugins/typing_settings/platform_utils/__pycache__/__init__.cpython-39.pyc
Binary file not shown.
Binary file added
BIN
+804 Bytes
globalPlugins/typing_settings/platform_utils/__pycache__/blackhole.cpython-39.pyc
Binary file not shown.
Binary file added
BIN
+2.32 KB
globalPlugins/typing_settings/platform_utils/__pycache__/clipboard.cpython-39.pyc
Binary file not shown.
Binary file added
BIN
+1.66 KB
globalPlugins/typing_settings/platform_utils/__pycache__/idle.cpython-39.pyc
Binary file not shown.
Binary file added
BIN
+5.08 KB
globalPlugins/typing_settings/platform_utils/__pycache__/paths.cpython-37.pyc
Binary file not shown.
Binary file added
BIN
+5.07 KB
globalPlugins/typing_settings/platform_utils/__pycache__/paths.cpython-39.pyc
Binary file not shown.
Binary file added
BIN
+978 Bytes
globalPlugins/typing_settings/platform_utils/__pycache__/process.cpython-39.pyc
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Replacement for py2exe distributed module | ||
# Avoids the use of the standard py2exe console. | ||
# Just import this file and it should go away | ||
|
||
import sys | ||
|
||
if hasattr(sys, "frozen"): # true only if we are running as a py2exe app | ||
|
||
class Blackhole(object): | ||
"""Mock file object that does nothing.""" | ||
|
||
def write(self, text): | ||
pass | ||
|
||
def flush(self): | ||
pass | ||
|
||
def isatty(self): | ||
return False | ||
|
||
sys.stdout = Blackhole() | ||
sys.stderr = Blackhole() | ||
del Blackhole | ||
del sys |
128 changes: 128 additions & 0 deletions
128
globalPlugins/typing_settings/platform_utils/clipboard.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
import platform | ||
|
||
|
||
def set_text_windows(text): | ||
""" | ||
Args: | ||
text: | ||
Returns: | ||
""" | ||
import win32clipboard | ||
import win32con | ||
|
||
win32clipboard.OpenClipboard() | ||
try: | ||
win32clipboard.EmptyClipboard() | ||
win32clipboard.SetClipboardText(text, win32con.CF_UNICODETEXT) | ||
finally: | ||
win32clipboard.CloseClipboard() | ||
|
||
|
||
def set_text_gtk(text): | ||
""" | ||
Args: | ||
text: | ||
Returns: | ||
""" | ||
import gtk | ||
|
||
cb = gtk.Clipboard() | ||
cb.set_text(text) | ||
cb.store() | ||
|
||
|
||
def set_text_osx(text): | ||
""" | ||
Args: | ||
text: | ||
Returns: | ||
""" | ||
scrap = True | ||
try: | ||
import Carbon.Scrap | ||
except ModuleNotFoundError: | ||
scrap = False | ||
if scrap: | ||
Carbon.Scrap.ClearCurrentScrap() | ||
scrap = Carbon.Scrap.GetCurrentScrap() | ||
scrap.PutScrapFlavor("TEXT", 0, text) | ||
else: | ||
try: | ||
text = text.encode() | ||
except AttributeError: | ||
pass | ||
import subprocess | ||
|
||
s = subprocess.Popen("pbcopy", stdin=subprocess.PIPE) | ||
s.communicate(text) | ||
|
||
|
||
def set_text(text): | ||
"""Copies text to the clipboard. | ||
Args: | ||
text: | ||
Returns: | ||
""" | ||
plat = platform.system() | ||
if plat == "Windows": | ||
set_text_windows(text) | ||
elif plat == "Linux": | ||
set_text_gtk(text) | ||
elif plat == "Darwin": | ||
set_text_osx(text) | ||
else: | ||
raise NotImplementedError("Cannot set clipboard text on platform %s" % plat) | ||
|
||
|
||
copy = set_text | ||
|
||
|
||
def get_text_windows(): | ||
""" """ | ||
import win32clipboard | ||
import win32con | ||
|
||
win32clipboard.OpenClipboard() | ||
try: | ||
text = win32clipboard.GetClipboardData(win32con.CF_UNICODETEXT) | ||
finally: | ||
win32clipboard.CloseClipboard() | ||
return text | ||
|
||
|
||
def get_text_osx(): | ||
""" """ | ||
import subprocess | ||
|
||
s = subprocess.Popen("pbpaste", stdout=subprocess.PIPE) | ||
result = s.communicate()[0] | ||
try: | ||
result = result.decode() | ||
except UnicodeDecodeError: | ||
pass | ||
return result | ||
|
||
|
||
def get_text(): | ||
""" """ | ||
plat = platform.system() | ||
if plat == "Windows": | ||
return get_text_windows() | ||
elif plat == "Darwin": | ||
return get_text_osx() | ||
else: | ||
raise NotImplementedError( | ||
"Cannot get text from clipboard on platform %s" % plat | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import platform | ||
|
||
system = platform.system() | ||
|
||
|
||
def get_user_idle_time(): | ||
""" | ||
Args: | ||
Returns: | ||
This is normally obtained from a lack of keyboard and/or mouse input. | ||
""" | ||
if system == "Windows": | ||
return get_user_idle_time_windows() | ||
elif system == "Darwin": | ||
return get_user_idle_time_mac() | ||
raise NotImplementedError("This function is not yet implemented for %s" % system) | ||
|
||
|
||
def get_user_idle_time_windows(): | ||
""" """ | ||
from ctypes import Structure, windll, c_uint, sizeof, byref | ||
|
||
class LASTINPUTINFO(Structure): | ||
""" """ | ||
_fields_ = [("cbSize", c_uint), ("dwTime", c_uint)] | ||
|
||
lastInputInfo = LASTINPUTINFO() | ||
lastInputInfo.cbSize = sizeof(lastInputInfo) | ||
windll.user32.GetLastInputInfo(byref(lastInputInfo)) | ||
millis = windll.kernel32.GetTickCount() - lastInputInfo.dwTime | ||
return millis / 1000.0 | ||
|
||
|
||
def get_user_idle_time_mac(): | ||
""" """ | ||
import subprocess | ||
import re | ||
|
||
s = subprocess.Popen(("ioreg", "-c", "IOHIDSystem"), stdout=subprocess.PIPE) | ||
data = s.communicate()[0] | ||
expression = "HIDIdleTime.*" | ||
try: | ||
data = data.decode() | ||
r = re.compile(expression) | ||
except UnicodeDecodeError: | ||
r = re.compile(expression.encode()) | ||
return int(r.findall(data)[0].split(" = ")[1]) / 1000000000 |
Oops, something went wrong.