Merge pull request #52 from quickgui/terminalemulators
Add support for more terminal emulators
This commit is contained in:
commit
d76a8de022
|
|
@ -29,6 +29,24 @@ class _ManagerState extends State<Manager> with PreferencesMixin {
|
||||||
bool _spicy = false;
|
bool _spicy = false;
|
||||||
final List<String> _sshVms = [];
|
final List<String> _sshVms = [];
|
||||||
String? _terminalEmulator;
|
String? _terminalEmulator;
|
||||||
|
final List<String> _supportedTerminalEmulators = [
|
||||||
|
'cool-retro-term',
|
||||||
|
'gnome-terminal',
|
||||||
|
'guake',
|
||||||
|
'mate-terminal',
|
||||||
|
'konsole',
|
||||||
|
'lxterm',
|
||||||
|
'lxterminal',
|
||||||
|
'pterm',
|
||||||
|
'sakura',
|
||||||
|
'terminator',
|
||||||
|
'tilix',
|
||||||
|
'uxterm',
|
||||||
|
'uxrvt',
|
||||||
|
'xfce4-terminal',
|
||||||
|
'xrvt',
|
||||||
|
'xterm'
|
||||||
|
];
|
||||||
Timer? refreshTimer;
|
Timer? refreshTimer;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|
@ -57,15 +75,18 @@ class _ManagerState extends State<Manager> with PreferencesMixin {
|
||||||
}
|
}
|
||||||
|
|
||||||
void _getTerminalEmulator() async {
|
void _getTerminalEmulator() async {
|
||||||
ProcessResult result = Process.runSync('x-terminal-emulator', ['-h']);
|
// Find out which terminal emulator we have set as the default.
|
||||||
RegExp pattern = RegExp(r"usage:\s+([^\s]+)", multiLine: true, caseSensitive: false);
|
ProcessResult result = await Process.run('which', ['x-terminal-emulator']);
|
||||||
RegExpMatch? match = pattern.firstMatch(result.stdout);
|
if (result.exitCode == 0) {
|
||||||
if (match != null) {
|
String terminalEmulator = await File(result.stdout.toString().trim()).resolveSymbolicLinks();
|
||||||
|
terminalEmulator = path.basenameWithoutExtension(terminalEmulator);
|
||||||
|
if (_supportedTerminalEmulators.contains(terminalEmulator)) {
|
||||||
setState(() {
|
setState(() {
|
||||||
_terminalEmulator = match.group(1);
|
_terminalEmulator = path.basename(terminalEmulator);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void _detectSpice() async {
|
void _detectSpice() async {
|
||||||
ProcessResult result = await Process.run('which', ['spicy']);
|
ProcessResult result = await Process.run('which', ['spicy']);
|
||||||
|
|
@ -278,6 +299,46 @@ class _ManagerState extends State<Manager> with PreferencesMixin {
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
IconButton(
|
||||||
|
icon: Icon(
|
||||||
|
Icons.delete,
|
||||||
|
color: active ? null : buttonColor,
|
||||||
|
semanticLabel: 'Delete'
|
||||||
|
),
|
||||||
|
onPressed: active ? null : () {
|
||||||
|
showDialog<String?>(
|
||||||
|
context: context,
|
||||||
|
builder: (BuildContext context) => AlertDialog(
|
||||||
|
title: Text('Delete ' + currentVm),
|
||||||
|
content: Text(
|
||||||
|
'You are about to delete ' + currentVm + '. This cannot be undone. ' +
|
||||||
|
'Would you like to delete the disk image but keep the ' +
|
||||||
|
'configuration, or delete the whole VM?'
|
||||||
|
),
|
||||||
|
actions: [
|
||||||
|
TextButton(
|
||||||
|
child: Text('Cancel'),
|
||||||
|
onPressed: () => Navigator.pop(context, 'cancel'),
|
||||||
|
),
|
||||||
|
TextButton(
|
||||||
|
child: Text('Delete disk image'),
|
||||||
|
onPressed: () => Navigator.pop(context, 'disk'),
|
||||||
|
),
|
||||||
|
TextButton(
|
||||||
|
child: Text('Delete whole VM'),
|
||||||
|
onPressed: () => Navigator.pop(context, 'vm'),
|
||||||
|
) // set up the AlertDialog
|
||||||
|
],
|
||||||
|
),
|
||||||
|
).then((result) async {
|
||||||
|
result = result ?? 'cancel';
|
||||||
|
if (result != 'cancel') {
|
||||||
|
List<String> args = ['--vm', currentVm + '.conf', '--delete-' + result];
|
||||||
|
await Process.start('quickemu', args);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
),
|
||||||
],
|
],
|
||||||
)),
|
)),
|
||||||
if (connectInfo.isNotEmpty)
|
if (connectInfo.isNotEmpty)
|
||||||
|
|
@ -327,13 +388,24 @@ class _ManagerState extends State<Manager> with PreferencesMixin {
|
||||||
result = result ?? false;
|
result = result ?? false;
|
||||||
if (result) {
|
if (result) {
|
||||||
List<String> sshArgs = ['ssh', '-p', vmInfo.sshPort!, _usernameController.text + '@localhost'];
|
List<String> sshArgs = ['ssh', '-p', vmInfo.sshPort!, _usernameController.text + '@localhost'];
|
||||||
switch (_terminalEmulator) {
|
// Set the arguments to execute the ssh command in the default terminal.
|
||||||
|
// Strip the extension as x-terminal-emulator may point to a .wrapper
|
||||||
|
switch (path.basenameWithoutExtension(_terminalEmulator!)) {
|
||||||
case 'gnome-terminal':
|
case 'gnome-terminal':
|
||||||
case 'mate-terminal':
|
case 'mate-terminal':
|
||||||
sshArgs.insert(0, '--');
|
sshArgs.insert(0, '--');
|
||||||
break;
|
break;
|
||||||
case 'xterm':
|
case 'xterm':
|
||||||
|
case 'lxterm':
|
||||||
|
case 'uxterm':
|
||||||
case 'konsole':
|
case 'konsole':
|
||||||
|
case 'uxrvt':
|
||||||
|
case 'xrvt':
|
||||||
|
case 'sakura':
|
||||||
|
case 'cool-retro-term':
|
||||||
|
case 'pterm':
|
||||||
|
case 'lxterminal':
|
||||||
|
case 'tilix':
|
||||||
sshArgs.insert(0, '-e');
|
sshArgs.insert(0, '-e');
|
||||||
break;
|
break;
|
||||||
case 'terminator':
|
case 'terminator':
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue