#!/bin/bash CMD="/usr/bin/gpg --card-status" text="" tooltip="" alt="missing" ret=$($CMD 2> /dev/null) if [ $? -eq 0 ]; then tooltip="S/N $(echo $ret | grep -oE 'Serial number[.:0-9 ]*' | grep -oE '[0-9]*')" alt="available" fi json="{\"text\": \"$text\", \"tooltip\": \"$tooltip\", \"class\": \"card\", \"alt\": \"$alt\"}" echo $json