One-of-a-kind SpaceFM dialog boxes

After several tests with the file explorer SpaceFM and reading the manual of this program I could realize that it contains its own dialog boxes, and the best of all is that they can be integrated with each other, it will not be necessary to open another type of dialog box to perform a certain action. Thanks to the fact that these dialog boxes are specific to the program SpaceFM you won't have to load an external program to use them, thus reducing RAM memory consumption and speeding up operations between them.

Let's look at several examples of dialog boxes trying to imitate the normal operation of other dialog boxes, such as asking for confirmation to continue with a given process, choosing a list of options, etc.

  1. Notification or alert

     

    spacefm -g --hbox --icon notification-gsm-disconnected --hbox --label "Alerta de Seguridad Intruso en la RED" --button close

  2. Ask for confirmation to continue with a certain process:

     

    spacefm -g --hbox --icon gtk-stop --hbox --label "Esta seguro de continuar" --button no echo "falso" -- close --button yes echo "verdad" -- close 2>&1 |grep verdad > /dev/null && comando-a-continuación

  3. Enter a specific small text

     

    spacefm -g --hbox --icon gtk-edit --vbox --label "Teclee un texto cualquiera" --input --button ok | grep dialog_input1= | sed 's/dialog_input1=//' | awk -F "'*" '{print $2}' | grep [[:alnum:]]

  4. Enter multiple lines of text

     

    spacefm -g --hbox --icon gtk-edit --vbox --label "Teclee varias lineas de texto cualquiera" --window-size 500x300 --input-large --button ok | grep dialog_inputlarge1= | sed 's/dialog_inputlarge1=//' | awk -F "'*" '{print $2}' | grep [[:alnum:]]

  5. Enter a specific password

     

    spacefm -g --hbox --icon locked --vbox --label "Tecle la contraseña" --password --button ok | grep dialog_pasword1= | sed 's/dialog_password1=//' | awk -F "'*" '{print $2}' | grep [[:alnum:]]

  6. Text file viewer

     

    spacefm -g --hbox --icon gtk-edit --hsep --vbox --label "Visor de Archivos de Texto" --viewer /etc/fstab --button close > /dev/null

  7. Text file editor

     

    spacefm -g --hbox --icon gtk-edit --hsep --vbox --label "Visor de Archivos de Texto" --editor /etc/fstab --button cancel source /dev/null -- close --button save source $HOME/fichero-salida.txt -- close > /dev/null

    The image is similar to that of the text viewer.

  8. Dialog box «option selector» with drop-down menu and not editable.

     

    spacefm -g --label "Seleccione la acción a realizar" --drop "Listar" "Tamaño" "Borrar" "null" -- "Listar" --button cancel set drop1 "null" -- close --button ok | grep dialog_drop1= | sed 's/dialog_drop1=//' | awk -F "'*" '{print $2}' | sed 's/Listar/ls/' | sed 's/Tamaño/du -sh/' | sed 's/Borrar/rm -r/' | grep -v null

  9. Option selector dialog box with editable drop-down menu.

     

    spacefm -g --label "Seleccione la acción a realizar" --combo "Listar" "Tamaño" "Borrar" "null" -- "Listar" --button cancel set combo1 "null" -- close --button ok | grep dialog_combo1= | sed 's/dialog_combo1=//' | awk -F "'*" '{print $2}' | sed 's/Listar/ls/' | sed 's/Tamaño/du -sh/' | sed 's/Borrar/rm -r/' | grep -v null

    Image Similar to the previous one.

  10. Dialog box to list options and select 1 action.

     

    spacefm -g --label "Seleccione la acción a realizar" --list "Listar" "Tamaño" "Borrar" -- "Listar" --button cancel --button ok | grep dialog_list1= | sed 's/dialog_list1=//' | awk -F "'*" '{print $2}' | sed 's/Listar/ls/' | sed 's/Tamaño/du -sh/' | sed 's/Borrar/rm -r/' | grep [[:alnum:]]

  11. Dialog box to list options and select more than one action.

     

    spacefm -g --label "Seleccione la acción a realizar" --mlist "Opcion 1" "Opcion 2" "Opción 3" -- "Listar" --button cancel --button ok echo dia-"%"mlist1 -- close | grep dia- | sed 's/dia- //g' | sed 's/dialog_mlist1=//' | grep [[:alnum:]]

    Image Similar to the previous one.

  12. Dialog box to select files or directories:

     

    spacefm -g --chooser /media/ --button cancel set chooser1 /dev/null -- close --button ok | grep dialog_chooser1= | awk -F \' '{print $2}'

    - File selector options
    –Save (Instead of choosing the input file, choose the output file)
    –Dir (Select Folders Only)
    –Multi (Select Multiple Files)
    –Filter (Filters the type of file that will be shown, it could be through the mimetype or the file extension)

    Example:

    –Filter text / plain
    –Filter '* .txt'
    –Filter '* .txt: *. Doc: *. Html' (Method to filter multiple extensions separated by colons:)

This was just one example of what these dialog boxes can do, since they can mostly be integrated into a single dialog box forming a new one-of-a-kind box:

  1. For example, if we want a dialog box to enter the password twice, we will only have to repeat the –password option 2 times. Let's look at an example where it checks that the passwords match before proceeding to take any action.

    To protect a PDF against copy by allowing reading (This method is only valid for working with a single PDF):

    spacefm -g --label "Teclee la contraseña" --password --label "Repita la Contraseña" --password --mlist "Printing" "DegradedPrinting" "ModifyContents" "CopyContents" "ScreenReaders" "ModifyAnnotations" "AllFeatures" --button aplicar bash -c "[ '"%"password1' = '"%"password2' ] && pdftk '"%f"' output '`basename %n | sed 's/\.[[:alnum:]]*$//'`-locked.pdf' allow "%"mlist1 owner_pw '""%"password1"' " -- close

    Note 1: To avoid expansion in the shell, enclose the entire command line to be executed in quotation marks by putting bash -c in front of it so that it interprets these lines, so we can use special operators such as & | among others.
    Note 2: As the commands are made between quotation marks «» they cannot be used to separate the blank fields instead they must use the single quotation mark »thus leaving '/ path / to / folder / file with space1', if they use some aliases such as% password must first separate the percent with double quotes and the alias with the percent between quotes and it is re-encapsulated with single quotes »thus leaving '» »%» password1 ″', if we are going to use the% fo symbology % n must first put it in double quotes and then in single quotes, thus making it '»% f»'.
    Note 3: If you want to protect it against opening, you just have to change the owner_pw option to user_pw.
  2. To establish an alias to each data that we have entered in the dialog box we can use the following form (useful when creating scripts):

     

    eval "`spacefm -g --input --input --button ok`"

    We can check that the value that we enter in the dialog box has been assigned input 1
    echo $dialog_input1

  3.  

  4. Search for certain files and choose to open or delete them:

     

    find %F -name *.txt > $HOME/.derr && SpaceFM -g --mlist @$HOME/.derr --button abrir bash -c "mimeopen -M "%"mlist1" --button borrar bash -c "rm "%"mlist1" – close && rm $HOME/.derr

    Accessories
    –Hsep (horizontal line)
    –Vsep (vertical line)
    –Button (button)
    –Free-button (Free button, which can be positioned in other areas than at the bottom of the window)
    –Hbox (to arrange buttons horizontally)
    –Vbox (To arrange buttons vertically)
    –Window-icon (Window icon)
    –Icon (Show an icon)
    –Label (To enter the text below the window frame)
    –Image (Similar to –icon option)
    –Timeout (Automatically close the window once the countdown ends)
    –Window-size (Select window size 600 × 400)

There are other ways of working with these dialog boxes either in scripts or in another way, for more documentation refer to the page of the manual of SpaceFM in the section Dialogue.


Leave a Comment

Your email address will not be published. Required fields are marked with *

*

*

  1. Responsible for the data: Miguel Ángel Gatón
  2. Purpose of the data: Control SPAM, comment management.
  3. Legitimation: Your consent
  4. Communication of the data: The data will not be communicated to third parties except by legal obligation.
  5. Data storage: Database hosted by Occentus Networks (EU)
  6. Rights: At any time you can limit, recover and delete your information.

  1.   Daniel De la Rosa said

    Impressive ... No Words. Approve!!!!

  2.   helena_ryuu said

    very good !, excellent article, let's try the tips ^^

  3.   Marcelo said

    Very complete article. These types of entries, so elaborate and detailed, are what give prestige and fame to a website. Congratulations!

  4.   hexborg said

    Amazing. I had no idea this could be done with spacefm. It seems more complete than xdialog or zenity. Very good article.

  5.   socrates_xD said

    For something reminds me of Glade

  6.   auroszx said

    I had no idea that SpaceFM could do that Oo