Quick Quality-of-Life Improvements

I’m using the super key (Windows key) for shortcuts that use the active window, but it could be the alt key for people without the super key.

super + s, opens setting
super + t, opens terminal
super + i, opens terminal in template (install)

5 Likes

We also have a lot of suggestions that use the same basic template.
Identify the active window -> do something.
Does this make sense? Wouldnt it be better to highlight that, and then
under subcategory put the various implementations.
(I should make it clear that I have no idea how this thread looks in
practice.)

I never presume to speak for the Qubes team.
When I comment in the Forum I speak for myself.

1 Like

I too use the Super key for many such shortcuts - the same super+s and
super+t bindings.

I never presume to speak for the Qubes team.
When I comment in the Forum I speak for myself.

4 Likes

I’m totally stealing this for opening qube’s template’s salt formula

2 Likes

@unman The main post relies heavily on markdown, so I’m sure it’ll look strange to you via email. I’d take a screenshot and post it, but I’m not even sure if images are included in the email posts (or if you’ve enabled images in your emails).

There’s some repetition since there’s an emphasis on readability and ease of use. Users should be able to spot something they like and have everything they need to implement it without chasing down references. I think we have a good balance between ease of use and density, and won’t have to go full DRY (Do Not Repeat yourself).

 

So right now the key set is super + s, t, i, esc. There should be some shortcut entries without anything but I don’t have time right now.

Will suggest users without super to substitute with alt where possible

Do the super combinations above clash with anything anyone knows of?

1 Like

Images are always an issue for me,tbh.

Thanks for that. I just thought there would be a space where someone
could say “I can use that to do…”

In KDE, I dont think there are significant clashes, or at least not in
my workflow. Users are always warned of clash with existing shortcuts.
Meta+t - toggle tiling

I never presume to speak for the Qubes team.
When I comment in the Forum I speak for myself.

Reusing this, it’s easy to open the file manager, whatever the template is:

#!/bin/sh

ID=`xdotool getwindowfocus`
QUBE=`xprop _QUBES_VMNAME -id $ID | cut -f 2 -d\"`

if [[ "$QUBE" == "$_QUBES_VMNAME:  not found." ]]; then
    exit
else
    qvm-run "$QUBE" /usr/bin/xdg-open /home/user &
fi
4 Likes

Added; thanks

Just want to double check that this works with typical installations for both Debian and Fedora.

Also, I assigned super + f to this, and updated relevant entries to include suggested shortcuts.

1 Like

Update for R4.3

The contents of this thread have been verified for R4.2 only.

There’s a small chance some tips may not work with R4.3 and above.

If you encounter any problems, please let us know!

At the moment of writing qvm-device DEVICE_CLASS assign / unassign throws an error if the system is already in the desired state. This gets in the way because there is no native device module for configuration management systems. You can trap the error and parse the message:

#!/usr/bin/env bash

(
    set -o errtrace
    set -o errexit
    set -o nounset

    action="$2"
    log=""

    parse_error() {
        if { 
            [[ "$action" == 'assign' ]] && [[ "$@" =~ .*(already assigned).* ]] 
        } || { 
            [[ "$action" == 'unassign' ]] && [[ "$@" =~ .*(not assigned).* ]] 
        }
        then
            echo "System is in the desired state"
            exit 0
        else
            echo "$@" >&2
            exit 1
        fi
    }
    trap 'parse_error "$log"' ERR

    log="$(qvm-device "$@" 2>&1)"
)

This is a hackjob, real module should be written instead. Note that you must specify device class for the script to work.

Asking the user for confirmation might be a better alternative in some cases. Luckily, Qubes OS has PyQt installed in dom0 by default, it can be used to make a simple confirmation dialog. Here’s what I ended up with:

#!/usr/bin/python3

import sys
from PyQt6.QtWidgets import QApplication
from PyQt6.QtWidgets import QDialog
from PyQt6.QtWidgets import QVBoxLayout
from PyQt6.QtWidgets import QHBoxLayout
from PyQt6.QtWidgets import QLabel
from PyQt6.QtWidgets import QPushButton

class ConfirmationDialog(QDialog):
    def __init__(
            self,
            title=None,
            message=None,
            parent=None
        ):
        super().__init__(parent)
        self.setWindowTitle("Confirm action" if title is None else title)
        label = QLabel("Are you sure?" if message is None else message)
        label.setWordWrap(True)

        layout = QVBoxLayout()
        layout.addWidget(label)

        self.setModal(False)
        self.setMinimumSize(1,1)

        button_layout = QHBoxLayout()

        yes = QPushButton("&Yes")
        no  = QPushButton("&No")

        yes.clicked.connect(self.accept)
        no.clicked.connect(self.reject)

        button_layout.addWidget(yes)
        button_layout.addWidget(no)

        layout.addLayout(button_layout)
        self.setLayout(layout)

def main():
    try:
        if len(sys.argv) == 3:
            title = sys.argv[1]
            message = sys.argv[2]
        else:
            sys.stderr.write(
                "Bad arguments were given. Usage:\n" +
                "{} TITLE MSG\n".format(sys.argv[0]) +
                "But my argument list is: {}\n".format(str(sys.argv[1:]))
            )
            return 3

        app = QApplication([])
        dialog = ConfirmationDialog(title,message)
        result = dialog.exec()
        app.exit()

        if result == QDialog.DialogCode.Accepted:
            return 0
        elif result == QDialog.DialogCode.Rejected:
            return 1
        else:
            return 2
    except:
        sys.stderr.write("{} ERROR: something went very wrong\n".format(sys.argv[0]))
        return 4

if __name__ == "__main__":
    sys.exit(main())

In the script:

confirm "Confirm shutdown" "Shut $target_vm down?" \
&& qvm-shutdown --wait "$target_vm"

By default PyQt’s confirmation dialog uses Esc for no and Enter for yes, good for keyboard-centric workflow.

2 Likes

I’m using a small py script that automatically pauses (qvm-pause and qvm-unpause) Qube’s if they are not focused in i3wm (with a list of exceptions of VMs for which this doesnt apply). This means half of my VMs don’t eat any ressources. Quite handy!

1 Like

Is the “Open file manager” still working on 4.3? I couldn’t get it to work. I don’t know where the mistake was. The content of the the executable file is correct. I ran:

chmod +x /bin/open_file_manager.sh

Then added the keyboard shortcut Super+f to

sh /bin/open_file_manager.sh

Nothing happens when type Super+f.

Is there a difference between “-f 2” placement?

CUR_VM=xprop _QUBES_VMNAME -id $CUR_WIN_ID | cut -d \" -f 2
QUBE=xprop _QUBES_VMNAME -id $ID | cut -f 2 -d\"

This script work fine:

#!/bin/sh

ID=xdotool getwindowfocus
QUBE=xprop _QUBES_VMNAME -id $ID | cut -f 2 -d\"

if [[ “$QUBE” == “$_QUBES_VMNAME:  not found.” ]]; then
exit
else
qvm-run “$QUBE” /usr/bin/xdg-open /home/user &
fi 

Thanks. I still have not been able to get it to work. Should the keyboard shortcut Super+f command be:

sh /bin/open_file_manager.sh

or

/bin/open_file_manager.sh

Or something else?

I tested both and neither are working.

This is my open_file_manager.sh

#!/bin/sh

ID=“xdotool getwindowfocus”
QUBE=‘xprop _QUBES_VMNAME -id $ID | cut -f 2 -d"’

if [[ “$QUBE” == “$_QUBES_VMNAME: not found.” ]]; then
exit
else
qvm-run “$QUBE” /usr/bin/xdg-open /home/user &
fi

I use a mapping to the somewhat more basic:

#!/usr/bin/bash
ID=$(xdotool getwindowfocus)
QUBE=$(xprop _QUBES_VMNAME -id $ID|cut -f2 -d\" )
if [[ "$QUBE" == "_QUBES_VMNAME:  not found." ]]; then
  exit
else
  qvm-shutdown --force $QUBE 
fi

I never presume to speak for the Qubes team. When I comment in the Forum I speak for myself.
2 Likes

@unman THANK YOU! it worked!! This is what worked:

#!/bin/sh

ID=$(xdotool getwindowfocus)
QUBE=$(xprop _QUBES_VMNAME -id $ID|cut -f2 -d\" )
if [[ "$QUBE" == "$_QUBES_VMNAME: not found." ]]; then
   exit
else
   qvm-run $QUBE /usr/bin/xdg-open /home/user
fi