Github Issue #8543 - Devices widget: Label recently-connected devices as “NEW”
On Sep 22, 2023 Jamke writes:
Search for new devices in the devices widget can be easy and reliable.
Currently it is not easy and the chance of mistake, selection of wrong device, is high.
This can lead to a security leak in case the USB device is a USB-Ethernet connector or other network device connected to vault or any offline qube by mistake.
The most common user case:
A. User inserts USB device in USB slot
B. User opens devices widget
C. User manually search among devices (block or not) for the new just-inserted device.
This user case has 2 problems:
A. User has to manually search though the list reading everything
B. The chance of mistake, selection of wrong device, is high.
And also writes:
How about showing some label or icon “NEW” near device name in the list that was not show in the previous time widget was open, and was inserted in the last, let’s say, 10 minutes.
The device should stay NEW after being shown for the first time for some small time like a minute to prevent it from loosing NEW icon after opening the widget menu fast twice.
Also connecting device to any qube should instantly make the device not NEW.
And finally adds:
It should cover the most common case: user inserts device (block device or not) and tries to connect it somewhere. He will instantly find the connected device. And no spoofing is possible if the system can process events of connections and disconnections.
When I think about it, I do not know why isn’t it a case in all OSes yet.
Diagnosis and Analysis
User request could be easily implemented. Qubes Devices widget is a part of qubes-desktop-linux-manager repository. It is written in PyGTK. We can simply add a timestamp to new devices object and show a NEW! label markup in red color after the devices names for 10 minutes (or any other period).
Solutions
Solution 1 - Implement what user wants
This would improve overall security and functionality.
Here is the patch for this solution.
diff --git a/qui/devices/actionable_widgets.py b/qui/devices/actionable_widgets.py
index 34c69f0..45f151a 100644
--- a/qui/devices/actionable_widgets.py
+++ b/qui/devices/actionable_widgets.py
@@ -34,6 +34,7 @@ gi.require_version('Gtk', '3.0') # isort:skip
from gi.repository import Gtk, GdkPixbuf, GLib # isort:skip
from . import backend
+import tile
def load_icon(icon_name: str, backup_name: str, size: int = 24):
@@ -401,7 +402,13 @@ class MainDeviceWidget(ActionableWidget, Gtk.Grid):
self.device_icon.set_valign(Gtk.Align.CENTER)
self.device_label = Gtk.Label(xalign=0)
- self.device_label.set_markup(device.name)
+
+ label_markup = device.name
+ if hasattr(device, "_connection_timestamp"):
+ if int(time.monotonic() - device._connection_timestamp) < 120:
+ label_markup += ' <span foreground="red"><b>NEW!</b></span>'
+ self.device_label.set_markup(label_markup)
+
if self.device.attachments:
self.device_label.get_style_context().add_class("dev_attached")
diff --git a/qui/devices/device_widget.py b/qui/devices/device_widget.py
index 386b282..0a9556c 100644
--- a/qui/devices/device_widget.py
+++ b/qui/devices/device_widget.py
@@ -20,6 +20,7 @@
from typing import Set, List, Dict
import asyncio
import sys
+import time
import importlib.resources
@@ -130,6 +131,7 @@ class DevicesTray(Gtk.Application):
for dev_name, dev in changed_devices.items():
if dev_name not in self.devices:
+ dev._connection_timestamp = time.monotonic()
self.devices[dev_name] = dev
self.emit_notification(
_("Device available"),
And here is the screenshot:
Solution 2 - Do not touch the Devices Widget
Leave the widget as it is. It is already bloated.
Solution 3 - Make it configurable
Allow a special host feature for NEW label timeout. 0 means disable. But default should be X seconds.
Collecting feedback
So if you have read this post till this point, what is your opinion? I personally prefer 120 seconds. 10 minutes is too much.