Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 41 additions & 4 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ main() {
local H_DEST
local HYPRSHOT_URL
local TEMP_DIR
local DOCPATH
local LICENSE_PATH
local README
local LICENSE
local REMOTE_README
local REMOTE_LICENSE

BASE_URL="https://raw.githubusercontent.com"
HGUI_REMOTE="${BASE_URL}/s-adi-dev/hyprshot-gui/refs/heads/main/src"
Expand All @@ -41,6 +47,12 @@ main() {
H_DEST="/usr/bin/${H_EXEC}"
HYPRSHOT_URL="${BASE_URL}/gustash/hyprshot/refs/heads/main/${H_EXEC}"
TEMP_DIR="$(mktemp --directory --suffix -HYPRSHOT-GUI)"
DOCPATH="/usr/share/hyprshot-gui/doc"
LICENSE_PATH="/usr/share/hyprshot-gui/licenses"
README="readme.md"
LICENSE="LICENSE"
REMOTE_README="${HGUI_REMOTE}/${README}"
REMOTE_LICENSE="${HGUI_REMOTE}/${LICENSE}"

super_user_check
hyprshot_requirements "$(which_distro_is_this)"
Expand Down Expand Up @@ -128,8 +140,21 @@ super_user_check() {
hyprshot_defaults() {

local configuration_defaults
local user_pic_dir

if [[ -z "${XDG_PICTURES_DIR}" ]]; then
if command -v xdg-user-dir; then
user_pic_dir="$(xdg-user-dir PICTURES)"
elif [[ -s "${HOME}/.config/user-dirs.dirs" ]]; then
# shellcheck source=/dev/null
source "${HOME}/.config/user-dirs.dirs"
user_pic_dir="${XDG_PICTURES_DIR}"
else
user_pic_dir="${HOME}/Pictures"
fi
fi
configuration_defaults="[Settings]
OutputDir = ${XDG_PICTURES_DIR}
OutputDir = ${user_pic_dir}
Delay = 0
NotifyTimeout = 5000
ClipboardOnly = False
Expand All @@ -154,11 +179,13 @@ hyprshot_obtain_raw() {
[${H_EXEC}]=${HYPRSHOT_URL}
[${HGUI_EXEC}]=${REMOTE_EXEC}
[${HGUI_DESK}]=${REMOTE_DESK}
[${README}]=${REMOTE_README}
[${LICENSE}]=${REMOTE_LICENSE}
)

for w in "${!wanted[@]}"; do
printf "\nObtaining %s \n\tfrom %s...\n" "${w}" "${wanted[${w}]}"
curl --silent --location --progress-bar --continue-at - "${wanted[${w}]}" --output "${TEMP_DIR}/${w}"
echo curl --silent --location --progress-bar --continue-at - "${wanted[${w}]}" --output "${TEMP_DIR}/${w}"
DOWNLOADED+=("${TEMP_DIR}/${w}")
done

Expand All @@ -170,8 +197,13 @@ hyprshot_installation() {

# local hyprshot_ver
# local hyprshotgui_ver
local readme_name
local license_name

# hyprshot_ver="$(hyprshot --version)"
# hyprshotgui_ver="$(hyprshot-gui --version)"
readme_name="$(basename "${REMOTE_README}")"
license_name="$(basename "${REMOTE_LICENSE}")"

printf "\nInstalling Hyprshot... (%s)\n" "${H_EXEC}"
"${PRIVUP}" install --verbose --compare --mode 755 "${TEMP_DIR}/${H_EXEC}" "${H_DEST}"
Expand All @@ -182,6 +214,11 @@ hyprshot_installation() {
printf "\nCopying HyprShot GUI desktop file... (%s)\n" "${HGUI_DESK}"
"${PRIVUP}" cp --verbose "${TEMP_DIR}/${HGUI_DESK}" "${HGUI_DESK_DEST}"

printf "\nCopying readme and license files... (%s,%s)\n" "${readme_name}" "${license_name}"
"${PRIVUP}" mkdir --verbose "${DOCPATH}"
"${PRIVUP}" mkdir --verbose "${LICENSE_PATH}"
"${PRIVUP}" cp --verbose "${TEMP_DIR}/${HGUI_DESK}" "${HGUI_DESK_DEST}"

printf "\nInstallation process complete!\n\n"
}
#######################################
Expand All @@ -199,9 +236,9 @@ window_float_rule() {
mapfile -t config_files < <(grep --files-with-matches --extended-regexp --recursive "windowrule" "${HOME}/.config/hypr/")
hyprland_version="$(hyprland --version | awk 'NR==1 {print $2}' | cut --delimiter="." --fields=2 | tr --delete "\n")"
if [[ "${hyprland_version}" -gt 47 ]]; then
window_rule="windowrule = float, title:^(.*Hyprshot.*)$"
window_rule="windowrule = float, title:^(.*Hyprshot.*)$" # in line with Hyprland versions above 0.47.2
else
window_rule="windowrulev2 = float, title:^(.*Hyprshot.*)$"
window_rule="windowrulev2 = float, title:^(.*Hyprshot.*)$" # in line with Hyprland versions above 0.47.2
fi
key_line="# HyprShot GUI floating"
if [[ ${#config_files[@]} -ne 1 ]]; then
Expand Down
10 changes: 7 additions & 3 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,15 @@ hyprshot-gui -o ~/Screenshots -d 3 --clipboard-only

## Additional Configuration
To enhance the user experience, you can configure Hyprland to launch the application in floating mode by adding the following window rule to your Hyprland configuration:

For Hyprland until 0.47.2
```bash
windowrulev2 = float, title:^(.*Hyprshot.*)$
```
- **Note:** This rule is automatically added to your `~/.config/hypr/hyprland.conf` by the install script, so you don’t need to add it manually unless you want to verify or modify it.
```
From Hyprland from 0.48.0
```bash
windowrule = float, title:^(.*Hyprshot.*)$
```
- **Note:** The Install script tries to add this rule is automatically if it finds only one file containing window rules like `~/.config/hypr/hyprland.conf` or a modular approach `~/.config/hypr/conf/rules.conf`. Finding more than one file with window rules, it won't try to add the rule.

## Contributing
If you'd like to contribute, feel free to submit pull requests or report issues.
Expand Down