------------------------------------------------------------------------------ Window Control (vital for handling windows via scripts) xdotool General perpose X Window control tool xwit basic window moving/resizing focus (can move move too) wmctrl -l List all the application windows (add -G for icon/position/size) xwininfo window information (title, size, location) xkill basic window kill Shell GUI Popup programs Xdialog Simple on based on the TTY "dialog" GUI xmessage Display text and multi-choice buttons zentity Common for linux but seems to be 'static'. yad Fork of zentity (yet another dialog) Allows you to have multiple input fields (seems complex) https://github.com/v1cont/yad https://yad-guide.ingk.se/ gtkdialog Generate a full GUI interface to a script. sub-shell 'actions' are generated (a bit like openbox WM) can store things in variables for later actions http://code.google.com/p/gtkdialog/ http://pclosmag.com/html/Issues/200910/page21.html notify-send temporary message popup.. (requires d-bus) xmessage Display information and a number of buttons gxmessage A newer GTK version (now just called xmessage) xprompt String input entry program xmenu popup a menu of choices notifier pops up a window whenever input is received (error reporting) and many other window control utility programs Also see "WindowID.hints" for finding and using a windows ID And for password see "../crypto/passwd_input.txt" Note: zenity and yad are GTK. To get stock icon names run "gtk-demo" and double clicking "Stock Item and Icon Browser" ------------------------------------------------------------------------------ Error Message Popup Window remains until user presses button. See my x-windows script "error_message" Xdialog --title 'Failure' --msgbox "$@" 0x0 & xmessage -name $PROGNAME -title 'Failure' -center \ -buttons 'OK:0' -default 'OK' \ -xrm '*message.borderWidth: 0' \ -xrm '*message.scrollVertical: Never' \ "$@" & zenity --title 'Failure' --error --text="$@" & ------------------------------------------------------------------------------ Notify Message Popup Popup a temporary window with a message. No grabs or other interferance to user, just a informational message. May need some coordination to prvent popups from overlaying each other. The trick is to make them small, and somehow avoid overlapping other existing notification pops! See my x-windows script "notify_message" for a general solution https://antofthy.gitlab.io/software#notify_message ------------------------------------------------------------------------------ Zenity notification, with changing icon! This requires DBus to be running! ( i=9; while [ $i -gt 0 ]; do echo icon:projects/im/images/font_$i.gif sleep 1 i=`expr $i - 1` done ) | zenity --notification --listen ------------------------------------------------------------------------------ Zenity and Percentage Bars. Warning: with no input zenity -progress will go CPU bound! This is not good. ( i=5; while [ $i -gt 0 ]; do echo $i sleep 1 i=`expr $i + 5` done ) | zenity --progress ------------------------------------------------------------------------------ Using colors and columns in a list dialog... # Input file LOGFILE=${1:-/var/log/messages} # Seperate the input into paragraphs or entry, one line per column PARSER='BEGIN { OFS="\n" } { font=""; color="#FFFFFF" tag=substr($5,0,index($5,":")-1) msg=substr($0,index($0,$6)) }; /kernel/ { font="italic" }; /warn/ { color="#FFF4B8" }; /error/ { color="#FFD0D8" }; tag=="audit" {next}; # ignore audit messages msg~/^audit/ {next}; # ignore kernel audit messages too { print $1 " " $2, $3, $4, tag, msg, font, color; fflush(); }' tail -n100 $LOGFILE | awk "$PARSER" | \ yad --title="Log viewer" --window-icon=logviewer \ --button=gtk-close --geometry 600x350 \ --list --text="Content of $LOGFILE" \ --column Date --column Time --column Host \ --column Tag --column Message:TIP \ --column @font@ --column @back@ Note the awk script colors whole lines! ------------------------------------------------------------------------------- gtkdialog This creates a large 'dialog XML text' that whill generate a dialog then make bash script sub-shell calls. Various dialog elements can be stored into variables for use in those calls Calls could be pre-defined 'export -f' bash functions. Note sub-shell actions may pop up other windows using other dialog programs. Actually it seems to be a special scripting language that calls bash sub-shells to perform actions. (like many openbox) Main Page http://code.google.com/p/gtkdialog/ Good Example (at bottom) http://pclosmag.com/html/Issues/200910/page21.html Tips http://www.murga-linux.com/puppy/viewtopic.php?t=38608 ------------------------------------------------------------------------------ Add a Icon image inside a window permanently Using xwininfo get the window id, and its size and position (to root window) NOTE: make sure you pick the appropriate child of the window. xloadimage -windowid 0xWINDOWID -at X,Y IMAGE xrefresh -geometry WIDTHxHEIGHT+X+Y This sets the background pixmap of the window to the a blank white image the size of the window with a copy of the IMAGE at the prosition given. The xrefresh will then get the client to redraw the other parts of the window. This image will be refreshed automatically by the X server whenever required. Do not use this technique for a large window to save server memory. Example add to the current xterms window: image=${1:-/usr/include/bitmaps/std/finger.xbm} child=`xwininfo -children -id $WINDOWID | sed -n 's/^ *\(0x[^ ]*\).*/\1/p'` xloadimage -windowid $child -at 420,10 $image ------------------------------------------------------------------------------ To kill a specific client Kill a client that is runing on the display without asking the user to do so. Example: Look for a xv client. NOTE: This could easily get it wrong. xkill -id `xwininfo -all -children -root | awk '/\"xv\"/ {print $1; exit}'` a winkill 'xkill -id `xwininfo -all -children -root |\\\ awk '\''/\"\!:*\"/ {print $1; exit}'\''`' Better to use the windows title for xwininfo. This must however be exact so a version or patch upgrade could invalidate it. ------------------------------------------------------------------------------ Colormap hints xv -clear To remove unused color table entries. This does not include the colors used by the root pixmap. xv -root -quit Clear unused colors including the root pixmap colors. ------------------------------------------------------------------------------ Automation with "visgrep" "visgrep" is part of the "xautomation" package. Information in using it has moved to https://antofthy.gitlab.io/info/apps/visgrep.txt ------------------------------------------------------------------------------