qubes manager add start terminal

117 views
Skip to first unread message

Eva Star

unread,
Apr 16, 2017, 7:29:14 PM4/16/17
to qubes-users
I'm get tired that Qubes Manager till now do NOT have "Start Terminal"
at right click menu of each vm, but only "Run command in VM".

I want to patch it to add "Run terminal". I found that need to
duplicate "Run command" entry, name it "Run Terminal" and predefined
"gnome-terminal" on the input field.

I need to modify action. On the repository I see actions at
mainwindow.ui file. But I can not find it on the disk to add new action!

<action name="action_run_terminal">
<property name="icon">
<iconset resource="resources.qrc">
<normaloff>:/run-command.png</normaloff>:/run-command.png</iconset>
</property>

Where is mainwindow.ui with actions???

If I will found it I will add new function to process this action by
duplicating action_run_command_in_vm_triggered(self) and predefined
"gnome-terminal" into it.


--
Regards

Reg Tiangha

unread,
Apr 16, 2017, 7:44:23 PM4/16/17
to qubes...@googlegroups.com
I don't know the answer to your question, but the problem with that is
that not every TemplateVM has gnome-terminal installed (for example, the
Fedora or Debian minimal templates). If you wanted to make something
more generic, you'd probably be safer with 'xterm' even though it isn't
as convenient to use. That's what gets called whenever you click on
'Update VM' (except in Whonix, where it's Konsole).

But if you're just doing it for yourself, you can launch whatever you want.

That said, being able to right-click in Qubes Manager and quickly launch
any kind of terminal program would be a super useful feature to have.


Unman

unread,
Apr 16, 2017, 8:11:04 PM4/16/17
to Eva Star, qubes-users
I've done some manager hacking myself - some of it now incorporated in
release.
If you dont want to build a package then you can simply start hacking in
/usr/lib64/python2.7/site-packages/qubesmanager.
(Back this up first, of course.)

Beside the ui elements in ui_mainwindow the slots are in main.py. If
you're going to hack these remember to remove the compiled files.
I'd recommend using xterm, as it's in all the templates afaik.

unman

Holger Levsen

unread,
Apr 17, 2017, 9:12:50 AM4/17/17
to qubes...@googlegroups.com
On Sun, Apr 16, 2017 at 05:44:12PM -0600, Reg Tiangha wrote:
> That said, being able to right-click in Qubes Manager and quickly launch
> any kind of terminal program would be a super useful feature to have.

absolutly.

should also have a customisable default list of terminals to try as well
as a prefered terminal per VM.


--
cheers,
Holger
signature.asc

Eva Star

unread,
Apr 17, 2017, 9:35:02 AM4/17/17
to qubes...@googlegroups.com
On 04/17/2017 02:44 AM, Reg Tiangha wrote:

> I don't know the answer to your question, but the problem with that is
> that not every TemplateVM has gnome-terminal installed (for example, the
> Fedora or Debian minimal templates). If you wanted to make something
> more generic, you'd probably be safer with 'xterm' even though it isn't
> as convenient to use. That's what gets called whenever you click on
> 'Update VM' (except in Whonix, where it's Konsole).
>
> But if you're just doing it for yourself, you can launch whatever you want.
>
> That said, being able to right-click in Qubes Manager and quickly launch
> any kind of terminal program would be a super useful feature to have.

It's a little hack for me. "gnome-terminal" predefined entry will be
enough to start with. I'm also see on the function that executed, that
it have vm objects and 99% sure that this object hold all prefs of VM.
Then it will be not hard to parse settings and add little more
statements for this predefined string:

Advanced Logic if you want:
- default value xterm or empty
- if the template name of the AppVM (or templateVM) contain "fedora"
then predefined value "gnome-terminal"
- if it's HVM then no values
- if AppVM name start with "win" then "cmd" or empty.

But as already noted: little hack with gnome-terminal will be enough to
start.

But the problem to find the file whereis right-click menu. As I can
understand, source file somehow "compiled" by Qt... I do not know how to
recompile them, because I'm new to python and know almost nothing about Qt.

--
Regards

Eva Star

unread,
Apr 17, 2017, 9:39:20 AM4/17/17
to qubes...@googlegroups.com
On 04/17/2017 03:11 AM, Unman wrote:

> I've done some manager hacking myself - some of it now incorporated in
> release.
> If you dont want to build a package then you can simply start hacking in
> /usr/lib64/python2.7/site-packages/qubesmanager.
> (Back this up first, of course.)
>
> Beside the ui elements in ui_mainwindow the slots are in main.py. If
> you're going to hack these remember to remove the compiled files.
> I'd recommend using xterm, as it's in all the templates afaik.
>

Unfortunately main.py contain only functions.
UI elements located not at qubesmanager dir. They are compiled? How?
Need to modify this file :
https://github.com/QubesOS/qubes-manager/blob/master/mainwindow.ui



--
Regards

Jean-Philippe Ouellet

unread,
Apr 17, 2017, 10:15:34 AM4/17/17
to Eva Star, qubes-users
Yes, they get "compiled" during package build like this [1]. You can
either invoke pyuic4 yourself, or just use qubes-builder to build new
qubes-manager packages and install them in dom0. I personally find the
build pkg & reinstall method easier.

[1]: https://github.com/QubesOS/qubes-manager/blob/46b892edb15f5fbc86b6f492ed4ffe61e2b1f491/Makefile#L19-L33

Unman

unread,
Apr 17, 2017, 6:13:31 PM4/17/17
to Eva Star, qubes...@googlegroups.com
Eva,

You've actually quoted the part where I tell you where the ui elements
are.

You can make this change directly in dom0 without building a package, by
editing the code in /usr/lib64/python2.7/site-packages/qubesmanager

As I said, main.py contains the slots (functions) and also the signals
that trigger them.

The simplest way to do what you want is to use the "Run command in VM"
structure as a template. You can search "command" and see how that is
implemented, and adapt it for your new purpose.


1. Define the function:
Copy the section defining the slot
(@pyqtSlot(name='on_action_run_command_in_vm_triggered'))
and the static method:
def do_run_command_in_vm(vm, command_to_run, thread_monitor):


You can pretty much just replace "command" with "xterm" throughout the
slot, and simplify because you arent prompting for a command to run:

@pyqtSlot(name='on_action_run_xterm_in_vm_triggered')
def action_run_xterm_in_vm_triggered(self):
vm = self.get_selected_vm()
thread_monitor = ThreadMonitor()
thread = threading.Thread(target=self.do_run_xterm_in_vm, args=(
vm, thread_monitor))
thread.daemon = True
thread.start()

while not thread_monitor.is_finished():
app.processEvents()
time.sleep(0.2)

if not thread_monitor.success:
QMessageBox.warning(None, self.tr("Error while running xterm"),
unicode(self.tr("Exception while running xterm:<br>{0}")).format(
thread_monitor.error_msg))

@staticmethod
def do_run_xterm_in_vm(vm, thread_monitor):
try:
vm.run('xterm', verbose=False, autostart=True,
notify_function=lambda lvl, msg: trayIcon.showMessage(
msg, msecs=3000))
except Exception as ex:
thread_monitor.set_error_msg(str(ex))
thread_monitor.set_finished()


2. Enable it when a row is selected.
Go to the table_selection_changed(self) function, and add in the new
function:
(again you can copy the action_run_command_in_vm details).
So in the main body of the function add:
self.action_run_xterm_in_vm.setEnabled(
not vm.last_power_state == "Paused" and vm.qid != 0)
and in the else clause:
self.action_run_xterm_in_vm.setEnabled(False)

3. Create the context menu item:
In __init__ section,
add a line below the line that adds the action_run_command_in_vm:
self.context_menu.addAction(self.action_run_xterm_in_vm)


4.
That's almost it:
But you need to add the new action to the Window. Again, you can look at
how action_run_command_in_vm is managed, and adapt it for your new menu
item. At a minimum you'll want entries in the setup and retranslate
functions.
So you'll want to add:
self.action_run_xterm_in_vm = QtGui.QAction(VmManagerWindow)
self.action_run_xterm_in_vm.setObjectName(_fromUtf8("action_run_xterm_in_vm"))
and
self.action_run_xterm_in_vm.setText(_translate("VmManagerWindow", "&Run xterm in VM", None))




That's pretty much done.

If you want to build a package just edit the files in the manager
directory, and run 'make manager'
The files you want there are qubesmanager/main.py and mainwindow.ui

As I said though, it's much simpler just to hack the source in dom0.
(Again, make sure you have backed up the originals.)

I hope this gives you the general idea - you can add all sorts of
context menus items, (including customizing the action to the VM.)

unman

Eva Star

unread,
Apr 17, 2017, 7:19:43 PM4/17/17
to qubes...@googlegroups.com
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

On 04/18/2017 01:13 AM, Unman wrote:

>
> unman
>

Thanks for this detailed manual, again, problem was with actions. I
will try later to do all of that. I think with your manual almost
somebody can do the same now.

- --
Regards
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2

iQIcBAEBCAAGBQJY9U2KAAoJEGSin3PC/C0ASB4P/2evYbd3CuI9XCzAF5SHuHe3
AdoUMJSW2MSZV1a126ONQWOKAwZ8YcuTLlKw55kk4Zu9jwU8wMJGkGJGPY9skCeA
welOhemlh3kZKixKM7ZH0h11J3d+YL54v62dOgrE3BgYkArePvjcfPgWh7lmIuRm
1WDrRE5XQ1vDhw8HkyI3lr5kppwMIVzUB0N4DEwSLwnj9VHMtiz8vAV00sG4Pf3F
l0n9Ox5pgpassN23QIyIuOLR9LNCLMmm2oY6ltgarJwOFugqi26IJgR5TJhIYOST
SseM9f0InA66lI6i/p2KdzW2WZrZel2Y99f55oxeGVQxj0iHmGd9LXmlVSUkcerN
TZzAJ88KKQfPqQt10MML/tGAWwCaM/PRa6Qdxdvg2SdniVWH0EQdeg/aqfIg/AVr
pw+2NHZokx/907QB/V92F6yAlUBjW/GoftgSVyLhGaO9GS7vzyO30e/5KIZ6gwlN
VfpUJ8UIgHU4mcmopaGbtBZYW+6T5xg4vOALAUwEcIGb1Dt+xysgIGxo9xVz6wva
cBeaR7O2iluXQ0Twv7TS4B9PBowKcFzIYc7TqbJl33CVPh42NgLbQCF12DtYbczB
sj0RwzbEsdN0uj76Gk575bzQXclWhiVRng5RTwS3QAYCvufXGWvXqwpeOLfo+i89
ZzkFEKGQFkmKEUS4ITJW
=ai/A
-----END PGP SIGNATURE-----

Manuel Amador (Rudd-O)

unread,
Apr 19, 2017, 7:59:49 PM4/19/17
to qubes...@googlegroups.com
Predefine "gnome-terminal || konsole || xterm" for more compatibility.

--
Rudd-O
http://rudd-o.com/

Reply all
Reply to author
Forward
0 new messages