tis-greenshot icon

Greenshot

Silent install package for Greenshot

1.3.296-16

  • package: tis-greenshot
  • name: Greenshot
  • version: 1.3.296-16
  • categories: Utilities
  • maintainer: WAPT Team,Tranquil IT,Jimmy PELÉ
  • editor: Thomas Braun,Jens Klingen,Robin Krom
  • licence: opensource_free,cpe:/a:gnu:gpl_v3,wapt_public
  • locale: all
  • target_os: windows
  • impacted_process: Greenshot
  • architecture: all
  • signature_date:
  • size: 3.73 Mo
  • installed_size: 3.81 Mo
  • homepage : https://getgreenshot.org/

package           : tis-greenshot
version           : 1.3.296-16
architecture      : all
section           : base
priority          : optional
name              : Greenshot
categories        : Utilities
maintainer        : WAPT Team,Tranquil IT,Jimmy PELÉ
description       : Greenshot is a free and open-source screenshot program
depends           : 
conflicts         : 
maturity          : PROD
locale            : all
target_os         : windows
min_wapt_version  : 2.1
sources           : https://github.com/greenshot/greenshot
installed_size    : 3807127
impacted_process  : Greenshot
description_fr    : Greenshot est un programme de capture d'écran gratuit et open-source
description_pl    : Greenshot to darmowy i open-source'owy program do tworzenia zrzutów ekranu
description_de    : Greenshot ist ein kostenloses und quelloffenes Screenshot-Programm
description_es    : Greenshot es un programa de captura de pantalla gratuito y de código abierto
description_pt    : O Greenshot é um programa de captura de ecrã gratuito e de código aberto
description_it    : Greenshot è un programma di screenshot gratuito e open-source
description_nl    : Greenshot is een gratis en open-source screenshot programma
description_ru    : Greenshot - бесплатная программа для создания скриншотов с открытым исходным кодом
audit_schedule    : 
editor            : Thomas Braun,Jens Klingen,Robin Krom
keywords          : greenshot,screenshot,screen,shot,program
licence           : opensource_free,cpe:/a:gnu:gpl_v3,wapt_public
homepage          : https://getgreenshot.org/
package_uuid      : 0016a49d-ba35-4030-ac07-6a217fc00e4f
valid_from        : 
valid_until       : 
forced_install_on : 
changelog         : https://github.com/greenshot/greenshot/releases
min_os_version    : 
max_os_version    : 
icon_sha256sum    : 05417a4a2a8d3a20390d0da8ffa7d5a82ad93f652d1d380df3f90fc70e516ad3
signer            : Tranquil IT
signer_fingerprint: 8c5127a75392be9cc9afd0dbae1222a673072c308c14d88ab246e23832e8c6bb
signature_date    : 2025-08-13T12:26:06.000000
signed_attributes : package,version,architecture,section,priority,name,categories,maintainer,description,depends,conflicts,maturity,locale,target_os,min_wapt_version,sources,installed_size,impacted_process,description_fr,description_pl,description_de,description_es,description_pt,description_it,description_nl,description_ru,audit_schedule,editor,keywords,licence,homepage,package_uuid,valid_from,valid_until,forced_install_on,changelog,min_os_version,max_os_version,icon_sha256sum,signer,signer_fingerprint,signature_date,signed_attributes
signature         : PpZsTKzZgFhoPs6pVa9TlCe8uILiFufdfpl9nS8pdlE/WPrJ8TE7n+H0eId/CWH/mnu9v3UlEiZM3Wm47OcIBwJ0veKifRInhxjr+SoM1eKiCLFa+CLKGiQb9A86cVjqm7u6pKug+6vPXwwv+8FbCJgk7AuiOvtNb3iSlMxbqFTxs0AeFA4laaHE88sXVYzz3BTWRZWyO24or9s3oGS7wD3C84jNvfCr5GTBcAuo43pBzKRa2tIE6bbKVUUEa7QhYvm3HxI2DbFVvqw6h4nfUiKkaR5YTpgaknEwLdQexRCiPrTDOB8iS2KZpJ1EcqPQ7kPPJOduz4Kc+/BcI+MaOw==

# -*- coding: utf-8 -*-
from setuphelpers import *
import chardet
import subprocess
import time
import winreg


def install():
    # Initializing variables
    bin_name = glob.glob("Greenshot-INSTALLER-*-RELEASE.exe")[0]
    basedir_conf_file = makepath(basedir, "install.inf")

    try:
        # Installing the package
        install_exe_if_needed(
            bin_name,
            silentflags="/LOADINF=install.inf /VERYSILENT /NORESTART /ALLUSERS",
            key="Greenshot_is1",
            min_version=control.get_software_version(),
            timeout=150,
        )
    except:
        # Fix Windows 11 unexpected timeout
        time.sleep(10)
        # Installing the package
        install_exe_if_needed(
            bin_name,
            silentflags="/LOADINF=install.inf /VERYSILENT /NORESTART",
            key="Greenshot_is1",
            min_version=control.get_software_version(),
            timeout=300,
        )


def session_setup():
    user_conf_dir = makepath(application_data, "Greenshot")
    user_conf_path = makepath(user_conf_dir, "Greenshot.ini")
    print(f"Updating: {user_conf_path}")
    if not isdir(user_conf_dir):
        mkdirs(user_conf_dir)

    registry_setstring(HKEY_CURRENT_USER,"Control Panel\Keyboard","PrintScreenKeyForSnippingEnabled",0,type=REG_DWORD)

    config_dict = {
        "UpdateCheckInterval": "UpdateCheckInterval=0",
        "Language": "Language=" + get_language(full_locale=True, separator="-"),  # fr-FR
        "Destinations": "Destinations=Picker",
        "CaptureMousepointer": "CaptureMousepointer=False",
    }
    user_screenshots_dir = makepath(user_home_directory, "Pictures", "Screenshots")
    if isdir(user_screenshots_dir):
        config_dict.update({"OutputFilePath": "OutputFilePath=" + user_screenshots_dir})

    base_file_str = r"""; Greenshot core configuration
[Core]
; The language in IETF format (e.g. en-US)
Language=fr-FR
; Is this the first time launch?
IsFirstLaunch=False
; Which destinations? Possible options (more might be added by plugins) are: Editor, FileDefault, FileWithDialog, Clipboard, Printer, EMail, Picker
Destinations=Editor
; Should the mouse be captured?
CaptureMousepointer=False
; How many days between every update check? (0=no checks)
UpdateCheckInterval=0
; Output file path.
OutputFilePath=C:\Users\username\Desktop
; If the target file already exists True will make Greenshot always overwrite and False will display a 'Save-As' dialog.
OutputFileAllowOverwrite=True
"""

    # Editting user_conf
    # killalltasks(control.get_impacted_process_list())
    killalltasks(["Greenshot"])

    edit_config_raw_file(user_conf_path, config_dict, base_file_str, encoding="UTF-8-SIG")
    subprocess.Popen([makepath(programfiles, "Greenshot", "Greenshot.exe")])


def edit_config_raw_file(conf_path, config_dict, base_file_str=None, encoding=None):
    r"""
    Edits a configuration file at the given path by replacing or adding key-value pairs from the provided dictionary.
    This function allows you to edit INI file with an incorrect format, flat file, dirty JSON, etc.

    Args:
        conf_path (str): The path to the configuration file.
        config_dict (dict): A dictionary containing key-value pairs to be updated or added in the configuration file.
            The key is strictly the string at the beginning of the line you are trying to edit.
            The value is the new replacing line.
            (Note: take care of spaces and tabs (\t). but line return (\n) will be added automatically.)
        base_file_str (str, optional): The base file content to be used if the configuration file doesn't exist. Defaults to None.
            (Note: The values from the `config_dict` do not need to be included in `base_file_str` explicitly,
            as they will be added automatically during the editing process.)
            (Make sure to check and define the encoding in this case.)
        encoding (str, optional): The encoding of the configuration file. If not specified, the function attempts to detect it. Defaults to None.

    Returns:
        dict: for key the previous line and value the new line of edited lines

    >>> edit_config_raw_file(user_conf_path, config_dict, base_file_str, encoding="UTF-8-SIG")
    dict({'Language=en-US\n': 'Language=fr-FR\n', 'Destinations=Picker\n': 'Destinations=Editor\n', 'CaptureMousepointer=True\n': 'CaptureMousepointer=False\n', 'OutputFilePath=C:\\Us...n\\Desktop\n': 'OutputFilePath=C:\\Us...reenshots\n', 'UpdateCheckInterval=14\n': 'UpdateCheckInterval=0\n'})

    .. versionadded:: 2.5

    """
    result_dict = {}
    if not encoding and os.path.isfile(conf_path):
        encoding = detect_file_encoding(conf_path)
    else:
        encoding = "UTF-8"

    if not os.path.isfile(conf_path):
        if not base_file_str:
            error("You did not provide a base_file_str, so the file needs to be present")
        with open(conf_path, "w", encoding=encoding) as f:
            f.write(base_file_str)
    new_lines = []
    with open(conf_path, "r", encoding=encoding) as f:
        for line in f:
            line_edited = False
            old_line = line
            line = line.rsplit("\n", 1)[0]
            for key, value in config_dict.items():
                if line.startswith(key):
                    line = value
                    line_edited = True
                    break
            new_line = line + "\n"
            new_lines.append(new_line)
            if line_edited:
                result_dict.update({old_line: new_line})

    with open(conf_path, "w", encoding=encoding) as f:
        f.writelines(new_lines)

    return result_dict


def detect_file_encoding(file_path):
    """Detect the encoding of a file."""
    with open(file_path, "rb") as file:
        raw_data = file.read()
        result = chardet.detect(raw_data)
        return result["encoding"]

# -*- coding: utf-8 -*-
from setuphelpers import *
import json


def update_package():
    # Declaring local variables
    package_updated = False
    proxies = get_proxies()
    if not proxies:
        proxies = get_proxies_from_wapt_console()
    app_name = control.name
    api_url = "https://api.github.com/repos/greenshot/greenshot/releases/latest"

    # Getting latest version information from official sources
    print("API used is: %s" % api_url)
    json_load = json.loads(wgets(api_url, proxies=proxies))
    for download in json_load["assets"]:
        if "-RELEASE.exe" in download["name"]:
            download_url = download["browser_download_url"]
            version = json_load["tag_name"].split("-")[-1].replace("v", "")
            latest_bin = download["name"]
            break

    # Downloading latest binaries
    print("Latest %s version is: %s" % (app_name, version))
    print("Download URL is: %s" % download_url)
    if not isfile(latest_bin):
        print("Downloading: %s" % latest_bin)
        wget(download_url, latest_bin, proxies=proxies)
    else:
        print("Binary is present: %s" % latest_bin)

    # Checking version from file
    version_from_file = get_version_from_binary(latest_bin).split("-")[0].split("+")[0]
    # if not version_from_file.startswith(version) and version_from_file != '':
    if Version(version_from_file) != Version(version) and version_from_file != "":
        print("Changing version to the version number of the binary")
        os.rename(latest_bin, latest_bin.replace(version, version_from_file))
        version = version_from_file
    else:
        print("Binary file version corresponds to online version")

    # Changing version of the package
    if Version(version) > Version(control.get_software_version()):
        print("Software version updated (from: %s to: %s)" % (control.get_software_version(), Version(version)))
        package_updated = True
    else:
        print("Software version up-to-date (%s)" % Version(version))
    control.set_software_version(version)
    control.save_control_to_wapt()

    # Deleting outdated binaries
    remove_outdated_binaries(version)

    # Validating update-package-sources
    return package_updated

98c29ebaf0d41caefe47873387b6b6ecc2812ad1dd4ae7b476f47a266b6aa376 : Greenshot-INSTALLER-1.3.296-RELEASE.exe
38d056ab130f7bf7c481c12636a4e9959de36561d3dfcbe54c6e3571bc0c1dc3 : WAPT/certificate.crt
2a321fca259d4865190cb9c0f7a7020b6eb7cf865a7b58cd516c56ac00fc479b : WAPT/control
05417a4a2a8d3a20390d0da8ffa7d5a82ad93f652d1d380df3f90fc70e516ad3 : WAPT/icon.png
b23c1355097c2562750315feb0acdf53998c9a02792a206953deff398ab7e97c : install.inf
cac9bb0ccaf80c4ddd3be0364cc152e7910986a9b7f1c78c3e1ca6619c65196c : luti.json
4bb7d7828ca1084d4e398efb803b9d578a0e64ff9bfd01cad18fe0b5b77c1916 : setup.py
5f2f47b0dd5b206c2ead3434fb1e2bef638c1ba799608ba1028841dcf4aec364 : update_package.py