Glib AppInfo.create_from_commandline with NEEDS_TERMINAL only launches xterm or gnome-terminal - glib

Why is this code only launching xterm or gnome terminal ?
I don't understand why it is not using user default terminal (x-terminal-emulator) on Debian, or even KDE default terminal.
AppInfo ai = AppInfo.create_from_commandline (
"ssh %s".printf (this.title),
"ssh", AppInfoCreateFlags.NEEDS_TERMINAL);
ai.launch (null, null);

Here is the list of what GDesktopAppInfo tries: gio/gdesktopappinfo.c#L2467-L2494
I believe the problem is that x-terminal-emulator is not standardized. If one were to push that as a freedesktop standard it would likely get implemented.

Related

How do I specify the Java VM which should be used to build the release during mvn unleash:perform?

I get build errors when using mvn unleash:perform because it tries to use the default Java VM to build the release instead of the one pointed to with JAVA_HOME or the one which was used to start the maven-unleash-plugin.
With -Dunleash.releaseArgs="--debug=true" -X, I can see that the outer Maven uses Java 11 and the inner uses 8.
I tried to fix this with:
mvn unleash:perform -Dunleash.releaseEnvironment="JAVA_HOME=$JAVA_HOME" -X |& tee mvn.log
but that leads to an NPE:
Caused by: java.lang.NullPointerException
at com.itemis.maven.plugins.unleash.steps.actions.BuildProject.setupInvocationRequest (BuildProject.java:123)
at com.itemis.maven.plugins.unleash.steps.actions.BuildProject.execute (BuildProject.java:73)
Is changing the default VM in Windows my only option?
In my case, the culprit was in .mavenrc (Linux) or %USERPROFILE%\mavenrc_pre.cmd (Windows, also check %USERPROFILE%\mavenrc_pre.bat). There, JAVA_HOME was hardcoded to some specific path.
The fix is to a) only set JAVA_HOME when it has no value and b) to display a warning (with path) when the variable is set. That way, people can't get confused by some silent behavior.
Solution in .mavenrc:
if [[ -z "$JAVA_HOME" ]]; then
export JAVA_HOME=...
echo "~/.mavenrc: Setting JAVA_HOME to $JAVA_HOME"
fi
For %USERPROFILE%\mavenrc_pre.cmd, use:
if "%JAVA_HOME%"=="" (
set JAVA_HOME=...
echo %USERPROFILE%\mavenrc_pre.cmd: Setting JAVA_HOME to %JAVA_HOME%
)

Why QProcess is not showing stdout from bash script executed in remote server?

I made an script (findx.h) that doesn't have any problem when i ran it on Solaris server via console (bash-3.2$ ./findx.sh)
The problem appears when i try to run it from a windows Qt app using QProcess (code below) where it doesn't display the ouput of the command.
I tried little variations and appear to show data when just use one pipe instead of two. But i need the two: grep and ggrep.
//findx.h in solaris
//WHAT WORKS
#!/bin/bash
echo pass | sudo -S /usr/sbin/snoop -x0 -ta HSM1000 port 1000
//WHAT I WANT
#!/bin/bash
echo pass | sudo -S /usr/sbin/snoop -x0 -ta HSM1000 port 1000 | /usr/sfw/bin/ggrep -A 2 KR01
//Qt on windows
QString commands="(";
commands +="source setpath.sh";
commands +=";/path/to/script/findx.sh";
commands +=")";
this->logged=false;
QString program = "plink.exe";
QStringList arguments;
arguments <<"-ssh"
<<ip
<<"-l"
<<user
<<"-pw"
<<pass
<<commands;
this->myProcess=new QProcess(this);
connect(this->myProcess,SIGNAL(started()),
this, SLOT(onprocess_started()));
connect(this->myProcess, SIGNAL(errorOccurred(QProcess::ProcessError)),
this, SLOT(onprocess_errorOcurred(QProcess::ProcessError)));
connect(this->myProcess, SIGNAL(finished(int, QProcess::ExitStatus)),
this, SLOT(onprocess_finished(int, QProcess::ExitStatus)));
connect(this->myProcess, SIGNAL(readyReadStandardError()),
this, SLOT(onprocess_readyReadStandardError()));
connect(this->myProcess, SIGNAL(readyReadStandardOutput()),
this, SLOT(onprocess_readyReadStandardOutput()));
connect(this->myProcess, SIGNAL(stateChanged(QProcess::ProcessState)),
this, SLOT(onprocess_stateChanged(QProcess::ProcessState)));
this->myProcess->start(program, arguments);
this->ui->labStatus->setText("Starting");
return 0;
// How i read, i do the same for stderr and put it also in plainOutput
QByteArray err=this->myProcess->readAllStandardOutput();
QString m="Standard output:"+QString(err.data());
this->ui->plainOutput->appendPlainText(m);
please any advice would be useful.
Thanks in advance.

How to define a custom prompt in JShell from a script?

I am trying to create a custom JShell prompt and want to load it from a file directly.
But it is not showing the custom prompt when loading the set prompt from a file, but I am able to do it writing the same commands on JShell.
Ex:
I have a file 'jshell_prompt_file' contains these 3 lines to set the prompt:
/set mode genspice -quiet
/set prompt genspice "GetNetConnectivity > " "--------> "
/set feedback genspice
When I load the file while invoking JShell, it does not change the prompt.
1:31am [login1] ~/JSHELL 1023:-)jshell jshell_prompt_file
| Welcome to JShell -- Version 13.0.2
| For an introduction type: /help intro
jshell>
But when I copy-paste the same command to set feedback, then it changes it
2:53am [login1] ~/JSHELL 1034:-)jshell jshell_prompt_file
| Welcome to JShell -- Version 13.0.2
| For an introduction type: /help intro
jshell> /set feedback genspice
GetNetConnectivity >
Can someone help me to achieve this without the user have to type it on command prompt? I want the first prompt to be the custom prompt.
The feedback mode need to be set with a specific JShell command line option : --feedback.
In your file jshell_prompt_file keep only the first two lines:
/set mode genspice -quiet
/set prompt genspice "GetNetConnectivity > " "--------> "
and run JShell with:
jshell jshell_prompt_file --feedback genspice

nix-shell can't find standard attribute

I'm running nixos 19.09 and trying to follow along with the instructions for creating a ruby package. But in one of the first steps I'm getting an error that the withPackages attribute can't be found.
Command:
$ nix-shell -p "ruby.withPackages (ps: with ps; [ nokogiri pry ])" --show-trace
Result:
while evaluating the attribute 'buildInputs' of the derivation 'shell' at /nix/store/b6cqdsczmwxfkmc65483x7fgwdl129ar-nixpkgs-19.03.173684.c8db7a8a16e/nixpkgs/pkgs/build-support/trivial-builders.nix:7:14:
while evaluating 'getOutput' at /nix/store/b6cqdsczmwxfkmc65483x7fgwdl129ar-nixpkgs-19.03.173684.c8db7a8a16e/nixpkgs/lib/attrsets.nix:464:23, called from undefined position:
while evaluating anonymous function at /nix/store/b6cqdsczmwxfkmc65483x7fgwdl129ar-nixpkgs-19.03.173684.c8db7a8a16e/nixpkgs/pkgs/stdenv/generic/make-derivation.nix:141:17, called from undefined position:
attribute 'withPackages' missing, at (string):1:94
I'm guessing that I messed up my nix store somehow, but I don't know how to debug it.
Additional Info:
$ echo $NIX_PATH
$HOME/.nix-defexpr/channels:nixpkgs=/nix/var/nix/profiles/per-user/root/channels/nixos:nixos-config=/etc/nixos/configuration.nix:/nix/var/nix/profiles/per-user/root/channels
$ nix-channel --list
nixpkgs https://nixos.org/channels/nixos-19.03
unstable https://nixos.org/channels/nixos-unstable
$ sudo nix-channel --list
<blank>
After #RobertHensing pointed out that it looked like I was on 19.03, and asked me to print out my channels, I tried just updating the channel list to point to 19.09 instead of 19.03 (with nix-channel --add) and that fixed it.

Kivy buildozer: how to deploy to specific android device

I have multiple devices (both AVDs and hardware) connected to my PC, but I want to deploy to a specific device with buildozer. How can I do that if disconnecting other devices is not an option?
Buildozer installs to android via adb. So you have to check the documentation of adb and check how it is modified in the buildozer startup script.
http://www.appsdeveloperblog.com/install-apk-on-device-adb/
and https://pypi.org/project/buildozer/
Think the command will be like
buildozer android deploy adb --s <DEVICE_NAME>
As on JAN 18 2020:
It seems like buildozer 1.0.1-dev0 does not have enough flexibility to accomplish this task. Commands like buildozer android deploy adb -s <DEVICE_ID> just ignore DEVICE_ID and install apk on all available devices.
There is a handy buildozer serve command, but that is slow and requires to manually answer to all security dialogs.
Using adb directly is a fair option, e.g.:
adb -s DEVICE_ID install -r your.apk
But if there are a lot of devices (armv7 and x86), it'd be a chore to type this every time. So I ended up with a script that is placed in the project directory:
import sys
import subprocess
# TODO: edit your custom settings
ADB_EXE = "/home/your_username/Android/Sdk/platform-tools/adb"
APK_X86 = "/path/to/apk/x86/bin/your_project__x86-0.1-x86-debug.apk"
APK_ARMV7 = "/path/to/apk/armv7/bin/your_project__armeabi-v7a-0.1-armeabi-v7a-debug.apk"
DEVICES = {
# DEVICE_PSEUDO_NAME: ("DEVICE_ID", "PATH_TO_APK")
"pixtab": ("emulator-5554", APK_X86),
"pix": ("emulator-5556", APK_X86),
"nexus4": ("004a900e1b268111", APK_ARMV7),
"nomi": ("SSI1216C111031288", APK_ARMV7),
}
def run():
global ADB_EXE
global DEVICES
if len(sys.argv) == 1:
print("Please, specify device.")
return
if sys.argv[1] == "list":
# print all available android devices
res = subprocess.check_output([ADB_EXE, "devices"])
for line in res.splitlines():
print(line)
return
dev_name = sys.argv[1]
print(f"Selected device: {dev_name}")
if dev_name not in DEVICES:
print(f"Device is not in the list, skipping.")
return
dev_id, apk = DEVICES[dev_name]
# "-r" means force install
res = subprocess.check_output([ADB_EXE, "-s", dev_id, "install", "-r", apk])
for line in res.splitlines():
print(line)
print(f"-- Deployment into {dev_id} complete.")
if __name__ == "__main__":
run()
To list all devices:
python3 dp.py list
To deploy specific apk to specific device:
python3 dp.py YOUR_DEVICE_PSEUDO_NAME

Resources