Menu

How to set colour syntax output in Custom Commands

Webmin
D L
2019-05-18
2019-05-19
  • D L

    D L - 2019-05-18

    I have Webmin with Authentic Theme installed in Ubuntu 16.04. After some period of dormancy, not using Webmin, I have revisited Webmin to build a catalogue of Custom Commands to hold CLI commands in use in development/deployment (Heroku, Google etc.).

    I have created Categories for main menu and cloned Custum Commands - all working fine including forms to set parameters for commands.

    However, I cannot recollect how to output coloured syntax through the command shell terminal. When I use local gnome-monitor terminal I can generate colour syntax.

    For example in gnome-terminal I run this command

    msgcat --color=test

    But if I run this same test command in Webmin Custom Command the output remains black/white.

    https://askubuntu.com/questions/27314/script-to-display-all-terminal-colors

    How do I get colour syntax in Custom Command output?

    A related question is how to apply colour to Execute button when running a Custom Command with a form? This will be a css setting somewhere in Authentic Theme.

     
  • D L

    D L - 2019-05-19

    After much researching I have found a workaround. Basically I can write a Webmin Command to launch Ubuntu gnome-terminal (bypassing Webmin shell terminal) and then when launched invoke xdotool to emulate key actions on gnome-terminal such as typing a command string.

    Here is the above colour test example written as a Webmin Command.

    export DISPLAY=:0 && gnome-terminal && xdotool type --delay 100 "msgcat --color=test" && xdotool key KP_Enter

    The export DISPLAY=:0 parameter is inserted to avoid an error if it is not used. This can be permanently set in environment to avoid setting this in every command.

     
  • D L

    D L - 2019-05-19

    I find that an added advantage of the setting export DISPLAY=:0 in the command string is that I can now launch applications directly from a Custom Command. In particular I can launch automation scripts which basically extend the Custom Commands library. I keep these in /etc/webmin-scripts/

     

Log in to post a comment.

MongoDB Logo MongoDB