I have been playing with SpaceFM's Dialog capabilities and have been very impressed with the way it works compared to Yad and Zenity. I'm surprised there are not more examples floating around. The easily implemented ability to watch a file and display changes makes completeing many tasks very straightforward.
#!/bin/bash# version: 2016-02-11 00:29# author: James Jordan james @ LiXCE.com#-------------------------------------------------------------------------------# Define the tempFile-----------------------------------------------------------# need to make a unique temp file and I like to be able to identify them# $$ inserts PID of script processexporttmpFile=/tmp/$USER-$$-df-LiXCE
# Create a function to process disk information---------------------------------
diskInfo(){# write the DF output to the temp file# Only uncomment ONE of the following lines# df -H > $tmpFile # Include all filesytems in Human readabel 1000'sdf-H-xdevtmpfs-xtmpfs>$tmpFile# Do not include tmp file systems# Strip off the header row, have to make my own to include spacefm control charssed-i'1d'$tmpFile# declare an array and pre-load it with my column headingsdeclare-aeachWD=("^Filesystem""^Size""^Used""^Avail""^Percent Full:progress""^Mounted")# add column widths to the arrayeachWD=("${eachWD[@]}""--colwidth=230""--colwidth=50""--colwidth=50""--colwidth=50""--colwidth=250""--colwidth=150")# Load each word of the text file into the array.forwordin$(<$tmpFile)doeachWD=("${eachWD[@]}""$word")done# everything has been read so we can reuse the temp fileecho-n"">$tmpFile# get length of arraynumWDs=${#eachWD[@]}# iterate through a compund loop to create the proper orderCOUNTA=0# we have 6 columns so the outerloop needs to iterate 6 timeswhile[$COUNTA-lt6];doCOUNTB=0# the inner loop iterates one time for each line in the file# plus once for the header and once for the column widthswhile[$COUNTB-lt$numWDs];doecho${eachWD[$COUNTA + $COUNTB]}>>$tmpFile# increment the count by 6letCOUNTB+=6doneletCOUNTA+=1donereturn0}export-fdiskInfo
# Create an autoUpdate function that runs every 11 minutes----------------------# 11 minutes keeps it from happening the same time every hour
autoUpdate(){sleep660diskInfo
autoUpdate
return0}# called from this shell level so do not need to export# PROCESSING BEGINS HERE--------------------------------------------------------# call the diskInfo function to provide initial display
diskInfo# Check the command line to see if we should automatically updateif["$1"=="-a"];then#call the autoUpdate function and continue processingautoUpdate&fi# Present the Spacefm dialog which is really very simple eval"$(spacefm-g\
--window-size"800x200"--titleLiXCE-Disk-Info\
--list--font"Roboto Bold 12"@/$tmpFile\
--button_Updatebash-cdiskInfo\
--buttonclose2>/dev/null)"# the 2>/dev/null supresses the gtk warnings# Clean up
rm$tmpFile# Turn out the lightsexit0
Last edit: Anonymous 2016-02-11
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thanks for the example. SpaceFM Dialog could use a How To as the manual is more of a reference (but does contain small examples). Also note that some plugins demonstrate Dialog use.
Also, I just added an Example Application plugin which demonstrates using a main loop to control a dialog.
Last edit: IgnorantGuru 2016-03-20
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
View and moderate all "General Discussion" comments posted by this user
Mark all as spam, and block user from posting to "Forum"
I have been playing with SpaceFM's Dialog capabilities and have been very impressed with the way it works compared to Yad and Zenity. I'm surprised there are not more examples floating around. The easily implemented ability to watch a file and display changes makes completeing many tasks very straightforward.
Last edit: Anonymous 2016-02-11
Thanks for the example. SpaceFM Dialog could use a How To as the manual is more of a reference (but does contain small examples). Also note that some plugins demonstrate Dialog use.
Also, I just added an Example Application plugin which demonstrates using a main loop to control a dialog.
Last edit: IgnorantGuru 2016-03-20