Skip to content

Instantly share code, notes, and snippets.

Created March 16, 2018 10:32
Show Gist options
  • Save anonymous/9e4e146b3579a5a610c2cd83784f093d to your computer and use it in GitHub Desktop.
Save anonymous/9e4e146b3579a5a610c2cd83784f093d to your computer and use it in GitHub Desktop.
diff --git a/nougat b/nougat
index b109713..9a6df26 100755
--- a/nougat
+++ b/nougat
@@ -16,9 +16,9 @@ saveourship(){
echo -e " -c - Puts the screenshot into your clipboard\n"
echo -e " -u - Hide cursor. (maim backend ONLY, see -b)"
echo " -b - Select backend to use"
- echo -e " Supported backends are \`maim', \`scrot', and \`imagemagick'."
+ echo -e " Supported backends are \`maim', \`scrot', \`imagemagick' and \`fbgrab'."
echo -e " nougat will detect available backends if -b"
- echo -e " is not specified. nougat prefers maim to scrot.\n"
+ echo -e " is not specified. nougat prefers maim to scrot, and fbgrab from the tty.\n"
echo " -p - Cleans the \`all' subdirectory of $NOUGAT_SCREENSHOT_DIRECTORY."
echo " Particularly useful as it cleans any links that no"
echo -e " longer point to a screenshot (i.e. deleted screeenshot).\n"
@@ -128,14 +128,32 @@ imagemagickbackend(){
}
+fbgrabbackend() {
+ local tmp="$(mktemp)"
+ cp /dev/fb0 "$tmp"
+ fbgrab -w 3200 -h 1800 -b 32 -f "$tmp" /tmp/nougat_temp.png
+}
+
+# To Do:
+# * This doesn't work with tmux (and possibly other multiplexers)
+# because they use a pseudo terminal (/dev/pts/[0-9]+), is there a better way?
+istty() {
+ local tty="$(tty)"
+
+ [[ "$tty" =~ "/dev/tty" ]] && return 0 || return 1
+}
+
runbackend(){
if [[ "$backend" == "" ]]
then
- command -v maim > /dev/null
+ istty
if [[ "$?" == "0" ]]
+ then
+ backend="fbgrab"
+ elif command -v maim > /dev/null
then
backend="maim"
else
@@ -158,6 +176,9 @@ runbackend(){
fi
case "$backend" in
+ fbgrab)
+ fbgrabbackend
+ ;;
maim)
maimbackend
;;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment