diff options
| author | 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> | 2025-01-17 16:58:50 +1100 |
|---|---|---|
| committer | 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> | 2025-01-17 16:58:50 +1100 |
| commit | ef5f9e34fe30c13a1fa3ce2999819da3b0773bce (patch) | |
| tree | f6ce0647b569d3578f97504f13a94b1758c35d28 | |
| parent | main: workspace action (diff) | |
| download | caelestia-cli-ef5f9e34fe30c13a1fa3ce2999819da3b0773bce.tar.gz caelestia-cli-ef5f9e34fe30c13a1fa3ce2999819da3b0773bce.tar.bz2 caelestia-cli-ef5f9e34fe30c13a1fa3ce2999819da3b0773bce.zip | |
screenshot script
| -rwxr-xr-x | change-wallpaper.fish | 2 | ||||
| -rwxr-xr-x | main.fish | 5 | ||||
| -rwxr-xr-x | screenshot.fish | 23 | ||||
| -rw-r--r-- | util.fish | 2 |
4 files changed, 31 insertions, 1 deletions
diff --git a/change-wallpaper.fish b/change-wallpaper.fish index 000a4c4..0bde3f2 100755 --- a/change-wallpaper.fish +++ b/change-wallpaper.fish @@ -31,7 +31,7 @@ if set -q _flag_h echo ' -F, --no-filter Do not filter by size' echo ' -t, --threshold <threshold> The minimum percentage of the size the image must be greater than to be selected (default '$threshold')' else - set -q XDG_CACHE_HOME && set cache_dir $XDG_CACHE_HOME/caelestia/wallpaper || set cache_dir ~/.cache/caelestia/wallpaper + set cache_dir $CACHE/wallpaper # The path to the last chosen wallpaper set last_wallpaper_path "$cache_dir/last.txt" @@ -18,6 +18,11 @@ if test "$argv[1]" = shell exit end +if test "$argv[1]" = screenshot + ./screenshot.fish $argv[2..] + exit +end + if test "$argv[1]" = workspace-action ./workspace-action.sh $argv[2..] exit diff --git a/screenshot.fish b/screenshot.fish new file mode 100755 index 0000000..1798b3b --- /dev/null +++ b/screenshot.fish @@ -0,0 +1,23 @@ +#!/bin/fish + +. (dirname (status filename))/util.fish + +mkdir -p "$CACHE/screenshots" +set tmp_file "$CACHE/screenshots/$(date +'%Y%m%d%H%M%S')" +grim $argv $tmp_file; and wl-copy < $tmp_file; or exit 1 + +set action (notify-send -i 'image-x-generic-symbolic' -h "STRING:image-path:$tmp_file" \ + -a (basename (status current-filename)) --action='open=Open' --action='save=Save' \ + 'Screenshot taken' "Screenshot stored in $tmp_file and copied to clipboard") +switch $action + case 'open' + uwsm app -- swappy -f $tmp_file & disown + case 'save' + set save_file (uwsm app -- zenity --file-selection --save --title='Save As') + [ -z $save_file ] && exit 0 + if [ -f $save_file ] + uwsm app -- yad --image='abrt' --title='Warning!' --text-align='center' --buttons-layout='center' --borders=20 \ + --text='<span size="x-large">Are you sure you want to overwrite this file?</span>' || exit 0 + end + cp -f $tmp_file $save_file +end @@ -16,3 +16,5 @@ end function error -a text _out red ERROR $text $argv[2..] end + +set -q XDG_CACHE_HOME && set CACHE $XDG_CACHE_HOME/caelestia || set CACHE $HOME/.cache/caelestia |