Skip to content

Instantly share code, notes, and snippets.

@jpouellet
Last active June 16, 2019 09:30
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jpouellet/bbf51888aee69a266f200f37963b8b87 to your computer and use it in GitHub Desktop.
Save jpouellet/bbf51888aee69a266f200f37963b8b87 to your computer and use it in GitHub Desktop.
Qubes OS: Opens a file manager in the focused VM
#!/usr/bin/env perl
use strict;
use warnings;
sub open_file_manager {
my $vm = shift;
exec {'qvm-run'} ('qvm-run', '--', $vm, 'exec nautilus --new-window --no-desktop </dev/null >/dev/null') or die "qvm-run exec failed\n";
}
if (defined $ARGV[0]) {
open_file_manager $ARGV[0];
}
$_ = `xprop -notype -root _NET_ACTIVE_WINDOW`;
/^_NET_ACTIVE_WINDOW: window id # (?<id>0x[0-9a-f]+), 0x0$/m or die "unable to get active window\n";
$_ = `xprop -id "$+{id}" -notype _QUBES_VMNAME`;
if (/^_QUBES_VMNAME = \"(?<vm>[^\"]+)\"$/m) {
length $+{vm} or die "empty string VM is invalid\n";
open_file_manager $+{vm};
}
@jpouellet
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment