#!/bin/bash
export LANG=C
CURRENT_DEFAULT="$(lpstat -s | grep -F "$(lpoptions | tr ' ' '\n' | grep "device-uri=" | cut -d= -f2)" | cut -d: -f1 | cut -d' ' -f 3-)"
NEW_DEFAULT="$(lpstat -p | grep -F ".  enabled since" | awk '{ print $2 }' | xargs kdialog --title "Standarddrucker einstellen" --icon printer --default "$CURRENT_DEFAULT" --combobox Standarddrucker:)"

if [ ! -z "$NEW_DEFAULT" ] ; then
	lpoptions -d "$NEW_DEFAULT"
	notify-send "Standarddrucker gesetzt:" "Zukünftig wird $NEW_DEFAULT ausgewählt sein."
fi
