diff --git a/APKBUILD b/APKBUILD new file mode 100644 index 0000000..bf5c6cb --- /dev/null +++ b/APKBUILD @@ -0,0 +1,28 @@ +# Contributor: Marty Sluijtman +# Maintainer: Marty Sluijtman +pkgname=maim-utils +pkgver=1.0 +pkgrel=1 +pkgdesc="A few common screenshot options rolled into one script based on maim" +url="https://alpine.voidcruiser.nl" +arch="noarch" +license="GPL-3.0" +depends="libnotify maim xdotool" +makedepends="scdoc" +subpackages="$pkgname-doc + $pkgname-zsh-completion + " +source="https://alpine.voidcruiser.nl/src/$pkgname-$pkgver.tar.gz" + +build() { + return 0 +} + +package() { + make install PREFIX=/usr DESTDIR="$pkgdir" + install -Dm 644 zsh.completion "$pkgdir"/usr/share/zsh/site-functions/_$pkgname +} + +sha512sums=" +e73d7e82ea183521862e3e6e1d8967aa832290d16407edbf574474077e317ab8013c4f0fc792de09479f040e880e12a6cfecc5aa391bdaff7dabac43fd4b870f maim-utils-1.0.tar.gz +" diff --git a/LICENCE b/LICENCE new file mode 100644 index 0000000..859580b --- /dev/null +++ b/LICENCE @@ -0,0 +1 @@ +fiets diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..5b79ab7 --- /dev/null +++ b/Makefile @@ -0,0 +1,36 @@ +NAME = maim-utils +VERSION = 1.0 +DIRNAME= $(NAME)-$(VERSION) +MANPAGE = $(NAME).1 +MANPREFIX = $(PREFIX)/share/man + +$(MANPAGE): $(MANPAGE).scd + scdoc < $< > $@ + +dist: + mkdir -p $(DIRNAME) + cp -R $(NAME) $(MANPAGE).scd Makefile LICENCE README.md zsh.completion $(DIRNAME) + tar -cf $(DIRNAME).tar $(DIRNAME) + gzip $(DIRNAME).tar + rm -rf $(DIRNAME) + +clean: + rm $(MANPAGE) $(DIRNAME).tar.gz + +install: $(MANPAGE) + install -dm 0755 $(DESTDIR)$(PREFIX)/bin + install -m 0755 $(NAME) $(DESTDIR)$(PREFIX)/bin + install -dm 0755 $(DESTDIR)$(MANPREFIX)/man1 + install -m 0644 $(MANPAGE) $(DESTDIR)$(MANPREFIX)/man1 + +uninstall: + rm -f $(DESTDIR)$(PREFIX)/bin/$(NAME)\ + $(DESTDIR)$MANPREFIX)/man1/$(MANPAGE) + +package: dist + rsync --progress $(DIRNAME).tar.gz voidDroplet:/var/www/alpine/src/ + rm -f /var/cache/distfiles/$(NAME)* + abuild checksum + abuild -r + +.PHONY: all install dist uninstall package clean diff --git a/maim-utils b/maim-utils old mode 100644 new mode 100755 index 6d3f0a4..5c93905 --- a/maim-utils +++ b/maim-utils @@ -1,10 +1,47 @@ #!/bin/sh -saveDir="${SCROTDIR:-$HOME/Pictures/screenshots}" +savedir="${SCROTDIR:-$HOME/Pictures/Screenshots}" +filename="$savedir/$(date -Iseconds)_maim.png" + +# test whether the screenshot directory exists, if not, create it. +[ -d $savedir ] || mkdir -p $savedir fullscreen(){ - maim -ui root "$saveDir/$(date -Iseconds)_maim.png" - notify-send 'Maim utils' 'Shot entire screen' + maim -ui root "$filename" + notify-send 'Maim utils' "Shot entire screen and saved output to:\n\n$filename" } -fullscreen +selection(){ + maim -su "$filename" + notify-send 'Maim utils' "Shot selection and saved output to:\n\n$filename\n\nBe aware that the selection process can be cancelled using any keypress and that this won't show up due to xclip eating the exit status." +} + +focus(){ + maim -ui "$(xdotool getactivewindow)" "$filename" + notify-send 'Maim utils' "Shot focussed window and saved output to:\n\n$filename" +} + +clip_fullscreen(){ + maim -ui root | xclip -sel clip -t image/png + notify-send 'Maim utils' "Shot entire screen and sent it to the clipboard." +} + +clip_selection(){ + maim -su | xclip -sel clip -t image/png + notify-send 'Maim utils' "Shot selection and sent it to the clipboard.\nBe aware that the selection process can be cancelled using any keypress and that this won't show up due to xclip eating the exit status." +} + +clip_focus(){ + maim -ui "$(xdotool getactivewindow)" | xclip -sel clip -t image/png + notify-send 'Maim utils' "Shot focussed window and sent it to the clipboard." +} + +case $1 in + sel|selection) selection;; + sel-clip|clip-sel|clip-selection) clip_selection;; + full|fullscreen) fullscreen;; + full-clip|clip-full|clip-fullscreen) clip_fullscreen;; + focus) foucs;; + clip-focus|focus-clip) clip_focus;; + open|show|screenshots) xdg-open $savedir;; +esac diff --git a/maim-utils.1.scd b/maim-utils.1.scd new file mode 100644 index 0000000..6b4702f --- /dev/null +++ b/maim-utils.1.scd @@ -0,0 +1,11 @@ +maim-utils(1) + +# NAME + +maim-utils - A few common screenshot options rolled into one script based on maim + +# SYNOPSIS + +*maim-utils* __ + +*maim-utils* __ diff --git a/zsh.completion b/zsh.completion new file mode 100644 index 0000000..1b26bfa --- /dev/null +++ b/zsh.completion @@ -0,0 +1,6 @@ +#compdef maim-utils _maim-utils + +_arguments -C \ + "1: :(focus fullscreen selection clip-selection clip-fullscreen clip-focus)" \ + "*::args:->args" +_arguments : $arguments