+/config

my dotfiles and nix configuration

git clone https://git.julia.blue/+/config

Julia RyanFix cosmic screen captureef1174a

main
665 B22 linesraw
1#!/usr/bin/env bash
2
3set -o pipefail
4
5img_dir="${XDG_PICTURES_DIR-$HOME/images}"
6img_path="${img_dir}/latest_screenshot.png"
7tmp_path=/tmp/screenshot.png
8linkmove() {
9    mv -- "$1" "$2"
10    ln -sf -- "$2" "$3"
11}
12
13if [ "$XDG_SESSION_TYPE" == "wayland" ] ||
14    ! [ -z "$WAYLAND_DISPLAY" ]; then
15    { if [ $# = 1 ]; then slurp | grim -g- -; else grim -; fi; } |
16        tee $tmp_path | wl-copy -t image/png
17else
18    maim -u"$1" |
19        tee $tmp_path | xclip -selection clipboard -t image/png
20fi &&
21    linkmove "$tmp_path" "$img_dir/screenshots/$(date +%s).png" "$img_path" &&
22    notify-send -u low -a screenshot -i monitor -h int:transient:1 'screenshot taken'