将截图上载到sftp服务器的简短脚本

dont_puush_me的Python项目详细描述


挑战现有工具捕获和上传的简易性 截图,以便公众可以看到,这个脚本是 制造的。

唯一需要的依赖项是scpscrot。可选依赖项 是:

  • optipng(默认情况下使用,可在配置中关闭)
  • xclip(将URL保存到剪贴板或从剪贴板捕获PNG图像)
  • zenity(在窗口中显示URL)

配置

上载url是使用配置文件dont-puush-me.ini配置的。它可以 放在xdg配置路径中的任何位置(通常是~/.config/etc/xdg)。

配置文件的格式如下:

[upload]
scp_format=user@host:/path/to/directory/{}.png
url_format=https://host.example/directory/{}.png

[process]
optipng=true

[to-selections]
primary=false
secondary=false
clipboard=false

scp_formaturl_format设置是必需的,没有默认设置 对他们来说是存在的。其中,第一次出现的{}替换为 自动生成图像的文件名。你需要设置这些值 以便scp可用于上载文件,以便可以访问该文件 在之后由url_format给出的url。

optipng设置是一个布尔设置,用于启用或禁用 上载图像前默认使用optipng。

to-selections部分为每个x11提供一个布尔标志 选择。它们默认为false,可以由命令行标志覆盖。 url被放入每个选择中,这些选择通过以下方式设置为true 命令行参数或配置文件。

用法

这个工具有很多选项,但实际使用通常很简单。为了 示例向下滚动。以下是完整用法:

usage: dont-puush-me [-h] (-f | -r | -c | -l FROM_FILE) [-d SECONDS]
                     [--no-optipng | --optipng] [--save-locally FILE] [-z]
                     [-p] [--no-to-primary] [-s] [--no-to-secondary] [-b]
                     [--no-to-clipboard] [-v]

Use scrot to create a screenshot which is either saved locally or uploaded to
a configured server.

optional arguments:
  -h, --help            show this help message and exit
  -v, --verbose         Increase verbosity

Capture settings:
  -f, --fullscreen      Make a shot of the entire screen
  -r, -w, --select      Select a region or window to screenshot
  -c, --from-clipboard  Use the image from the clipboard
  -l FROM_FILE, --from-file FROM_FILE
                        Use the image in the given PNG file
  -d SECONDS, --delay SECONDS
                        Delay the screenshot by the given amount of seconds

Image processing:
  --no-optipng          Disable use of optipng before uploading (overrides
                        config option)
  --optipng             Enable use of optipng before uploading (overrides
                        config option)

Upload settings:
  --save-locally FILE   Save the file locally instead of uploading it to a
                        server

URL output settings:
  -z, --zenity          Show the URL using zenity
  -p, --to-primary      Save the URL in the primary X11 selection (overrides
                        config option).
  --no-to-primary       Do not save the URL in the primary X11 selection
                        (overrides config option).
  -s, --to-secondary    Save the URL in the secondary X11 selection (overrides
                        config option).
  --no-to-secondary     Do not save the URL in the secondary X11 selection
                        (overrides config option).
  -b, --to-clipboard    Save the URL in the clipboard X11 selection (overrides
                        config option).
  --no-to-clipboard     Do not save the URL in the clipboard X11 selection
                        (overrides config option).

示例:

  • 捕获全屏截图并将生成的url复制到主x11 选择:

    dont-puush-me -fp
    
  • 从屏幕上捕获一个矩形(使用鼠标拾取该矩形; 单击而不拖动将选择单击的窗口的矩形:

    dont-puush-me -r
    

    url被打印到终端。

  • 捕获矩形,不应用optipng并在窗口中显示url (需要zenity):

    dont-puush-me --no-optipng -rz
    

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
JavaEclipseMars没有保存首选项   java梯度同步失败:原因:启动失败:   java如何从嵌套的JSON获取数据?   java如何判断可观察对象中的任何对象满足一个条件?   java将字符串转换为保持相同值的byte[]数组   java有没有办法绕过AuditingEntityListener为测试设置数据?   从/usr/share/java中解析linux JAR依赖关系   安卓 My java函数抛出nullpointerexception?   java Gradle使用正确版本的依赖项   JBoss和Java6中带注释的WebService中的web服务ClassCastException   java如何修复codename one中的简单逻辑错误?   java如何迭代矩阵的索引?   java如何在JPanel不可见时将其保存为图像?   java HashMap如何在Kotlin中实现MutableMap接口?   javascript如何在单击后加载特定片段?   EclipseJava为纳什均衡获取所有玩家/策略组合   JavaSpring:Web服务REST在JSON上产生双反斜杠   java为什么ServletContext#getRealPath(“/”)返回相对路径?   java当我的游戏应该重新启动时,我应该如何处理重置SurfaceView和线程?