From 596f85e4cdb88b93cbf3511988fa37ff31b4e7b0 Mon Sep 17 00:00:00 2001 From: "Matthieu Fortin (CPC/CCP)" Date: Fri, 1 Nov 2024 14:48:23 -0400 Subject: [PATCH] added --- README.md | 9 +++ scripts/.local/bin/Sounds.sh | 19 +++++ scripts/.local/bin/screenshot.sh | 129 +++++++++++++++++++++++++++++++ 3 files changed, 157 insertions(+) create mode 100644 README.md create mode 100755 scripts/.local/bin/Sounds.sh create mode 100755 scripts/.local/bin/screenshot.sh diff --git a/README.md b/README.md new file mode 100644 index 0000000..75e732b --- /dev/null +++ b/README.md @@ -0,0 +1,9 @@ +## File not opening dolphin +install the following package + +> archlinux-xdg-menu + +Then run + + XDG_MENU_PREFIX=arch- kbuildsycoca6 + diff --git a/scripts/.local/bin/Sounds.sh b/scripts/.local/bin/Sounds.sh new file mode 100755 index 0000000..6bec1ea --- /dev/null +++ b/scripts/.local/bin/Sounds.sh @@ -0,0 +1,19 @@ +#!/bin/bash +## /* ---- 💫 https://github.com/JaKooLit 💫 ---- */ ## +# This script is used to play system sounds. + +# Set the directory for system sounds. +sDIR="/usr/share/sounds/freedesktop/stereo" + +# Set to true to mute the system sounds. +muted=false + +if [[ "$muted" = true ]]; then + exit 0 +fi + +if [[ "$1" == "--shutter" ]]; then + pw-play "$sDIR/camera-shutter.oga" +elif [[ "$1" == "--volume" ]]; then + pw-play "$sDIR/audio-volume-change.oga" +fi diff --git a/scripts/.local/bin/screenshot.sh b/scripts/.local/bin/screenshot.sh new file mode 100755 index 0000000..821dd71 --- /dev/null +++ b/scripts/.local/bin/screenshot.sh @@ -0,0 +1,129 @@ +##!/bin/bash +## /* ---- 💫 https://github.com/JaKooLit 💫 ---- */ ## +# Screenshots scripts + +iDIR="$HOME/.config/swaync/icons" +sDIR="$HOME/.local/bin" +notify_cmd_shot="notify-send -h string:x-canonical-private-synchronous:shot-notify -u low -i ${iDIR}/picture.png" + +time=$(date "+%d-%b_%H-%M-%S") +dir="$(xdg-user-dir)/Pictures/Screenshots" +file="Screenshot_${time}_${RANDOM}.png" + +active_window_class=$(hyprctl -j activewindow | jq -r '(.class)') +active_window_file="Screenshot_${time}_${active_window_class}.png" +active_window_path="${dir}/${active_window_file}" + +# notify and view screenshot +notify_view() { + if [[ "$1" == "active" ]]; then + if [[ -e "${active_window_path}" ]]; then + ${notify_cmd_shot} "Screenshot of '${active_window_class}' Saved." + "${sDIR}/Sounds.sh" --screenshot + else + ${notify_cmd_shot} "Screenshot of '${active_window_class}' not Saved" + fi + elif [[ "$1" == "swappy" ]]; then + ${notify_cmd_shot} "Screenshot Captured." + else + local check_file="$dir/$file" + if [[ -e "$check_file" ]]; then + ${notify_cmd_shot} "Screenshot Saved." + "${sDIR}/Sounds.sh" --screenshot + else + ${notify_cmd_shot} "Screenshot NOT Saved." + fi + fi +} + + + +# countdown +countdown() { + for sec in $(seq $1 -1 1); do + notify-send -h string:x-canonical-private-synchronous:shot-notify -t 1000 -i "$iDIR"/timer.png "Taking shot in : $sec" + sleep 1 + done +} + +# take shots +shotnow() { + cd ${dir} && grim - | tee "$file" | wl-copy + sleep 2 + notify_view +} + +shot5() { + countdown '5' + sleep 1 && cd ${dir} && grim - | tee "$file" | wl-copy + sleep 1 + notify_view + +} + +shot10() { + countdown '10' + sleep 1 && cd ${dir} && grim - | tee "$file" | wl-copy + notify_view +} + +shotwin() { + w_pos=$(hyprctl activewindow | grep 'at:' | cut -d':' -f2 | tr -d ' ' | tail -n1) + w_size=$(hyprctl activewindow | grep 'size:' | cut -d':' -f2 | tr -d ' ' | tail -n1 | sed s/,/x/g) + cd ${dir} && grim -g "$w_pos $w_size" - | tee "$file" | wl-copy + notify_view +} + +shotarea() { + tmpfile=$(mktemp) + grim -g "$(slurp)" - >"$tmpfile" + if [[ -s "$tmpfile" ]]; then + wl-copy <"$tmpfile" + mv "$tmpfile" "$dir/$file" + fi + rm "$tmpfile" + notify_view +} + +shotactive() { + active_window_class=$(hyprctl -j activewindow | jq -r '(.class)') + active_window_file="Screenshot_${time}_${active_window_class}.png" + active_window_path="${dir}/${active_window_file}" + + hyprctl -j activewindow | jq -r '"\(.at[0]),\(.at[1]) \(.size[0])x\(.size[1])"' | grim -g - "${active_window_path}" + sleep 1 + notify_view "active" +} + +shotswappy() { + tmpfile=$(mktemp) + grim -g "$(slurp)" - >"$tmpfile" && "${sDIR}/Sounds.sh" --screenshot && notify_view "swappy" + swappy -f - <"$tmpfile" + rm "$tmpfile" +} + + +if [[ ! -d "$dir" ]]; then + mkdir -p "$dir" +fi + +if [[ "$1" == "--now" ]]; then + shotnow +elif [[ "$1" == "--in5" ]]; then + shot5 +elif [[ "$1" == "--in10" ]]; then + shot10 +elif [[ "$1" == "--win" ]]; then + shotwin +elif [[ "$1" == "--area" ]]; then + shotarea +elif [[ "$1" == "--active" ]]; then + shotactive +elif [[ "$1" == "--swappy" ]]; then + shotswappy +else + echo -e "Available Options : --now --in5 --in10 --win --area --active --swappy" +fi + +exit 0 +