mirror of
https://github.com/rwinkhart/sshyp.git
synced 2026-09-03 15:47:18 -04:00
Added warning if relevant clipboard tool is not installed
Former-commit-id: 2d89d7954a6d1c0133f235862e78b1bcfdcef9ff Former-commit-id: 988a751409f02e2b065c461d4c3f723472ee725a
This commit is contained in:
@@ -330,6 +330,19 @@ def tweak():
|
|||||||
_config_file.write('n')
|
_config_file.write('n')
|
||||||
print(f"{_divider}configuration complete\n")
|
print(f"{_divider}configuration complete\n")
|
||||||
|
|
||||||
|
# PORT START CLIPTOOL
|
||||||
|
# check for clipboard tool and display warning if missing
|
||||||
|
if uname()[0] in ('Linux', 'FreeBSD'):
|
||||||
|
if 'WAYLAND_DISPLAY' in environ:
|
||||||
|
_display_server, _clipboard_tool = 'Wayland', 'wl-clipboard'
|
||||||
|
else:
|
||||||
|
_display_server, _clipboard_tool = 'X11', 'xclip'
|
||||||
|
from shutil import which
|
||||||
|
if which(_clipboard_tool) is None:
|
||||||
|
print(f'\u001b[38;5;9mwarning: you are using {_display_server} and "{_clipboard_tool}" is not present -'
|
||||||
|
f'\ncopying entry fields will not function until "{_clipboard_tool}" is installed\u001b[0m\n')
|
||||||
|
# PORT END CLIPTOOL
|
||||||
|
|
||||||
|
|
||||||
# prints help text based on argument
|
# prints help text based on argument
|
||||||
def print_info():
|
def print_info():
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ _create_generic_linux() {
|
|||||||
# START PORT
|
# START PORT
|
||||||
cp -r lib/. port-jobs/working/
|
cp -r lib/. port-jobs/working/
|
||||||
cd port-jobs
|
cd port-jobs
|
||||||
|
./CLIPTOOL.py LINUX
|
||||||
./CLIPBOARD.py LINUX
|
./CLIPBOARD.py LINUX
|
||||||
./UNAME.py LINUX
|
./UNAME.py LINUX
|
||||||
./COMMENTS.py ALL
|
./COMMENTS.py ALL
|
||||||
@@ -152,6 +153,7 @@ urls {
|
|||||||
cd port-jobs
|
cd port-jobs
|
||||||
./SHEBANG.sh
|
./SHEBANG.sh
|
||||||
./RMSERVER.py
|
./RMSERVER.py
|
||||||
|
./CLIPTOOL.py
|
||||||
./CLIPBOARD.py HAIKU
|
./CLIPBOARD.py HAIKU
|
||||||
./COMMENTS.py ALL
|
./COMMENTS.py ALL
|
||||||
./UNAME.py TMP
|
./UNAME.py TMP
|
||||||
@@ -198,9 +200,11 @@ Installed-Size: 71680
|
|||||||
cp -r lib/. port-jobs/working/
|
cp -r lib/. port-jobs/working/
|
||||||
cd port-jobs
|
cd port-jobs
|
||||||
if [ "$1" = 'Debian' ]; then
|
if [ "$1" = 'Debian' ]; then
|
||||||
|
./CLIPTOOL.py LINUX
|
||||||
./CLIPBOARD.py LINUX
|
./CLIPBOARD.py LINUX
|
||||||
special=UBUNTU
|
special=UBUNTU
|
||||||
else
|
else
|
||||||
|
./CLIPTOOL.py
|
||||||
./CLIPBOARD.py WSL
|
./CLIPBOARD.py WSL
|
||||||
special=WSL-ONLY-UBUNTU
|
special=WSL-ONLY-UBUNTU
|
||||||
fi
|
fi
|
||||||
@@ -246,6 +250,7 @@ Installed-Size: 71680
|
|||||||
# START PORT
|
# START PORT
|
||||||
cp -r lib/. port-jobs/working/
|
cp -r lib/. port-jobs/working/
|
||||||
cd port-jobs
|
cd port-jobs
|
||||||
|
./CLIPTOOL.py
|
||||||
./CLIPBOARD.py TERMUX
|
./CLIPBOARD.py TERMUX
|
||||||
./UNAME.py TERMUX
|
./UNAME.py TERMUX
|
||||||
./COMMENTS.py ALL
|
./COMMENTS.py ALL
|
||||||
@@ -303,6 +308,7 @@ cp -r %%{_sourcedir}/usr %%{buildroot}
|
|||||||
# START PORT
|
# START PORT
|
||||||
cp -r lib/. port-jobs/working/
|
cp -r lib/. port-jobs/working/
|
||||||
cd port-jobs
|
cd port-jobs
|
||||||
|
./CLIPTOOL.py LINUX
|
||||||
./CLIPBOARD.py LINUX
|
./CLIPBOARD.py LINUX
|
||||||
./UNAME.py LINUX
|
./UNAME.py LINUX
|
||||||
./COMMENTS.py ALL
|
./COMMENTS.py ALL
|
||||||
@@ -363,6 +369,7 @@ printf "/usr/bin/sshyp
|
|||||||
# START PORT
|
# START PORT
|
||||||
cp -r lib/. port-jobs/working/
|
cp -r lib/. port-jobs/working/
|
||||||
cd port-jobs
|
cd port-jobs
|
||||||
|
./CLIPTOOL.py BSD
|
||||||
./CLIPBOARD.py TERMUX
|
./CLIPBOARD.py TERMUX
|
||||||
./UNAME.py TMP
|
./UNAME.py TMP
|
||||||
./COMMENTS.py ALL
|
./COMMENTS.py ALL
|
||||||
|
|||||||
Executable
+36
@@ -0,0 +1,36 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
import re
|
||||||
|
from sys import argv, exit as s_exit
|
||||||
|
|
||||||
|
# read arguments
|
||||||
|
arguments = argv[1:]
|
||||||
|
|
||||||
|
# define PORT target
|
||||||
|
string1 = '# PORT START CLIPTOOL'
|
||||||
|
string2 = '# PORT END CLIPTOOL'
|
||||||
|
|
||||||
|
# define replacement text depending on arguments
|
||||||
|
if len(arguments) > 0:
|
||||||
|
regex = re.compile(f"{string1}.*?{string2}", re.DOTALL)
|
||||||
|
replacement = """# check for clipboard tool and display warning if missing
|
||||||
|
if 'WAYLAND_DISPLAY' in environ:
|
||||||
|
_display_server, _clipboard_tool = 'Wayland', 'wl-clipboard'
|
||||||
|
else:
|
||||||
|
_display_server, _clipboard_tool = 'X11', 'xclip'
|
||||||
|
from shutil import which
|
||||||
|
if which(_clipboard_tool) is None:
|
||||||
|
print(f'''\u001b[38;5;9mwarning: you are using {_display_server} and "{_clipboard_tool}" is not present -
|
||||||
|
copying entry fields will not function until "{_clipboard_tool}" is installed\u001b[0m
|
||||||
|
''')"""
|
||||||
|
else:
|
||||||
|
regex = re.compile(f"{string1}.*?{string2}\n\n", re.DOTALL)
|
||||||
|
replacement = ''
|
||||||
|
|
||||||
|
# read input file
|
||||||
|
text = open('working/sshyp.py', 'r').read()
|
||||||
|
|
||||||
|
# find and replace the defined PORT target
|
||||||
|
new_text = re.sub(regex, replacement, text)
|
||||||
|
|
||||||
|
# write updated text
|
||||||
|
open('working/sshyp.py', 'w').write(new_text)
|
||||||
Reference in New Issue
Block a user