将截图上载到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第三方库


热门话题
java MenuInflater究竟是如何工作的?   用Java为每个循环查找一个元素   从1.3.2版开始,central maven中缺少java Springldap jar   多维java数组问题   java如何在StringProperty和组合框SelectedItemProperty之间进行双向绑定   java复制DynaBean的有效方法   ios Firestore分页数据+快照侦听器   java边界布局。该中心不与JPanel合作   C#和Java中的加密/解密   java List<String>List=newlinkedlist<>()与List List=newlinkedlist<String>()有什么区别?   java Android应用程序,包含传统和SL4A部分   java无法调用PowerMockito。@BeforeTest中的mockStatic   java My list viw未显示(Android Studio)   如何建立网络。基于java的xml在spring网页上的应用   java为Android设置按钮   如何在java中使用hashmap删除重复的数组元素   ssl Soundcloud JAVA api包装器:SSLPeerUnverifiedException