allow users to choose between escrotum and i3-scrot for screen capture
This commit is contained in:
parent
92b255d612
commit
caaba34666
@ -17,6 +17,12 @@ curl_command = None
|
|||||||
# This is where the screenshots are saved locally
|
# This is where the screenshots are saved locally
|
||||||
local_directory = '/home/kageru/pyshare/'
|
local_directory = '/home/kageru/pyshare/'
|
||||||
|
|
||||||
|
# Use i3scrot for screen capture. Otherwise, escrotum will be used.
|
||||||
|
# You might have to install the capture tool you want to use via your package manager.
|
||||||
|
# i3scrot was much faster for me when working with multiple high-res displays.
|
||||||
|
# If you do use it, you manually need to set its save directory to your local_directory (above) + 'tmp' in ~/.config/i3-scrot.conf
|
||||||
|
use_i3scrot = False
|
||||||
|
|
||||||
# Directory on the ftp server where you want the screenshots to be sent
|
# Directory on the ftp server where you want the screenshots to be sent
|
||||||
remote_directory = '/usr/share/nginx/html/pyshare/'
|
remote_directory = '/usr/share/nginx/html/pyshare/'
|
||||||
# Template for the link that the script will generate. {} is the filename
|
# Template for the link that the script will generate. {} is the filename
|
||||||
|
11
pyshare.py
11
pyshare.py
@ -46,12 +46,19 @@ def upload_local_file(path: str) -> str:
|
|||||||
|
|
||||||
def take_screenshot() -> None:
|
def take_screenshot() -> None:
|
||||||
tmppath = os.path.join(config.local_directory, 'tmp')
|
tmppath = os.path.join(config.local_directory, 'tmp')
|
||||||
|
if not os.path.isdir(tmppath):
|
||||||
|
os.mkdir(tmppath)
|
||||||
|
else:
|
||||||
tmpdir = os.listdir(tmppath)
|
tmpdir = os.listdir(tmppath)
|
||||||
for f in tmpdir:
|
for f in tmpdir:
|
||||||
os.remove(os.path.join(tmppath, f))
|
os.remove(os.path.join(tmppath, f))
|
||||||
# you can also use programs like escrotum here, but i3-scrot was much faster for me
|
if config.use_i3scrot:
|
||||||
call(['i3-scrot', '-s'])
|
call(['i3-scrot', '-s'])
|
||||||
file = os.path.join(config.local_directory, 'tmp', os.listdir(tmppath)[0])
|
file = os.path.join(tmppath, os.listdir(tmppath)[0])
|
||||||
|
else:
|
||||||
|
tempname = generate_filename(3, 'png')
|
||||||
|
call(['escrotum', '-s', tempname])
|
||||||
|
file = os.path.join(tmppath, tempname)
|
||||||
ftp_upload(ext='png', sourcefile=file)
|
ftp_upload(ext='png', sourcefile=file)
|
||||||
os.remove(file)
|
os.remove(file)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user