Wanting to get something like this added into the manager, just to execute the script for different things when they happen. the script itself I have built adds and removes the appropriate VM menus on the fly when it’s run, and I can cron it to run every few seconds.
However I would like to be able to run it when a guest starts or stops, and every time.
Also, to allow for the ability to have multiple locations for the menus themselves as well.
So at this time I have the following…
- Get the powered on guests.
- Have one folder that has all the configurations in it.
- Link back to the main folder for the ones that are active.
- Remove the links that are not powered on.
This reduces the size of the menu system to only what is powered on at the time.
Useful for those people that have many virtuals, but don’t always have them all turned on. So why have them in the menu when they can all be configured and powered on from the manager?
I know it’s not the prettiest way to achieve the desired result, but it works…
Firstly, add in to the /etc/xdg/menus/qubes-applications.menu the following…
Under “” tag" Powered Off" I put mine BEFORE the “” that preceeds the “”
So it looks like…
<Layout>
<Filename>xfce4-run.desktop</Filename>
<Filename>exo-terminal-emulator.desktop</Filename>
<Separator/>
<Menuname>System Tools</Menuname>
<Menuname>Qubes Tools</Menuname>
<Menuname>Powered Off</Menuname>
<Separator/>
<Merge type="all"/>
<Separator/>
<Filename>xfce4-session-logout.desktop</Filename>
</Layout>
This enables me to have the Powered Off folder available.
Altering the Applications in the SETTINGS of the machine will revert it back to the live area as it doesn’t retain the folder. But this could be changed I’m sure. However with the script it doesn’t really matter too much. As you can have it running every 30 seconds for what it mattered.
The actual script to run is as follows.
If I could run a script whenever a machine is altered, shutdown or started, then I would alter the script to perform the actions based on that, but at this time, this is what I have.
Anyone that has any suggestions on how to add it into the Qubes Startup and Shutdown and Settings Alteration of guests, I would be happy to hear.
#!/bin/sh
list=`xl list | grep -iw -Eo "^([^ ]+) " | awk 'NR>2'`
active=()
for ix in $list
do
active+=user-qubes-vm-directory-$ix.menu
done
lcv=1
lists=`find ~/.config/menus/applications-merged/user-qubes-*.menu*`
for i in $lists
do
sed -i -e 's/<Menu><Name>Powered Off<\/Name>//g' $i
sed -i -e 's/<\/Menu>//g' $i
if ! [[ ${active[*]} =~ ${i##*/} ]]; then
echo "Disabling ${i##*/}"
sed -i -e 's/<Name>Applications<\/Name>/<Name>Applications<\/Name><Menu><Name>Powered Off<\/Name>/g' $i
echo "</Menu></Menu></Menu>" >> $i
elif [[ ${active[*]} =~ ${i##*/} ]]; then
echo "Enabling ${i##*/}"
sed -i -e 's/<Name>Applications<\/Name><Menu><Name>Powered Off<\/Name>/<Name>Applications<\/Name>/g' $i
echo "</Menu></Menu>" >> $i
fi
done