Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

glib: Add support for GNOME Console #165975

Merged
merged 2 commits into from Mar 29, 2022
Merged

Conversation

jtojnar
Copy link
Contributor

@jtojnar jtojnar commented Mar 27, 2022

Description of changes

GNOME Console (aka King’s Cross) is the default terminal emulator in GNOME 42. Let’s make GLib aware of it so that apps relying on it (e.g. GNOME Shell) can launch terminal apps like htop.

This is a downstream patch since GLib does not want to add any more terminal emulators: https://gitlab.gnome.org/GNOME/glib/-/issues/2618

Things done
  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandbox = true set in nix.conf? (See Nix manual)
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 22.05 Release Notes (or backporting 21.11 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
    • (Release notes changes) Ran nixos/doc/manual/md-to-db.sh to update generated release notes
  • Fits CONTRIBUTING.md.

@jtojnar
Copy link
Contributor Author

jtojnar commented Mar 27, 2022

While at it, should we also add Pantheon Terminal @bobby285271 @davidak?

@bobby285271
Copy link
Member

bobby285271 commented Mar 28, 2022

While at it, should we also add Pantheon Terminal

Personally, this sounds good to me. I think -x should be used when calling io.elementary.terminal.


I actually have a very wired question for gnome-console, if I have a ~/.local/share/applications/test.desktop file as:

[Desktop Entry]
Type=Application
Version=1.0
Name=Test
GenericName=Test
Comment=Test
Icon=htop
Exec=/home/bobby285271/test.sh --randomarg
Terminal=true
Categories=System;ConsoleOnly;
Keywords=system

And a /home/bobby285271/test.sh executable file as:

#!/usr/bin/env bash
echo "hello"
if [[ "${1}" == "--randomarg" ]]
then
  echo "world"
fi
sleep 10

Can kgx -e handle the --randomarg arg correctly? I expect a terminal window pop up and say hello world.

@jtojnar
Copy link
Contributor Author

jtojnar commented Mar 28, 2022

Not sure, still have not rebuilt my system with this patch. I can only say that GNOME Terminal does print both lines when the script is started through the desktop file in GNOME Shell.


kgx -e "$PWD/test.sh --randomarg" and xterm -e "$PWD/test.sh --randomarg" need to be invoked like this, while gnome-terminal -- $PWD/test.sh --randomarg. io.elementary.terminal seems to support both formats (-x is synonym to --). kgx and io.elementary.terminal do not seem to close the tab after the command finishes, xterm and gnome-terminal do.

@jtojnar
Copy link
Contributor Author

jtojnar commented Mar 28, 2022

Actually, testing using the following shows that the patch is not sufficient as is:

$ env PATH=$(nix-build -A gnome-console)/bin $(nix-build https://github.com/jtojnar/nixpkgs/archive/glib-gnome-console.tar.gz -A glib.bin)/bin/gio launch ~/.local/share/applications/test.desktop
Unknown option --randomarg

@jtojnar jtojnar marked this pull request as draft March 28, 2022 09:50
@bobby285271
Copy link
Member

Not sure, still have not rebuilt my system with this patch.

I am actually testing the change using the "workaround" mentioned in the upstream issue, that is enable environment.localBinInPath, run ln -s /path/to/bin/kgx tilix in ~/.local/bin, create the above files, then gtk-launch test.desktop 🤣 And yeah I am also seeing Unknown option --randomarg.

@jtojnar
Copy link
Contributor Author

jtojnar commented Mar 28, 2022

Weirdly, having only xterm on PATH does not even seem to do anything. Not even when I remove the extra argument from the desktop file.

@jtojnar
Copy link
Contributor Author

jtojnar commented Mar 28, 2022

Interestingly, Tilix supports both tilix -e test.sh --randomarg and tilix -e "test.sh --randomarg" (I added test.sh on PATH).

Though going through a desktop file, it will work only when another Tilix window is running. Otherwise it will just print some startup warning and briefly open a window (immediately destroying it), and then do nothing.

@jtojnar
Copy link
Contributor Author

jtojnar commented Mar 28, 2022

The window closing immediately might have something to do with the PATH, it does the same when running env PATH=(nix-build -A xfce.xfce4-terminal)/bin result/bin/xfce4-terminal -x ~/.local/bin/test.sh --randomarg but not when passing it non-existent program, or running it without PATH modification result/bin/xfce4-terminal -x ~/.local/bin/test.sh --randomarg.

Edit: Turns out I need (nix-build -A bash)/bin:(nix-build -A coreutils)/bin (Bash for shebang, coreutils for sleep).

@jtojnar
Copy link
Contributor Author

jtojnar commented Mar 28, 2022

Testing with the following fish script and your desktop file, it seems all tested emulators support argument per argument, only KGX needs the whole command as a single argument.

for termpkg in gnome.gnome-terminal mate.mate-terminal xfce.xfce4-terminal gnome-console tilix libsForQt5.konsole xterm
echo Testing $termpkg
env PATH=(nix-build -A bash)/bin:(nix-build -A coreutils)/bin:(nix-build -A $termpkg)/bin (nix-build https://github.com/jtojnar/nixpkgs/archive/glib-gnome-console.tar.gz -A glib.bin)/bin/gio launch ~/.local/share/applications/test.desktop
read foo --prompt-str="Enter to continue"
end

GNOME Console (aka King’s Cross) is the default terminal emulator in GNOME 42.
Let’s make GLib aware of it so that apps relying on it (e.g. GNOME Shell)
can launch terminal apps like htop.

This is a downstream patch since GLib does not want to add any more
terminal emulators: https://gitlab.gnome.org/GNOME/glib/-/issues/2618
Just like we did for GNOME’s in the parent commit.
@jtojnar
Copy link
Contributor Author

jtojnar commented Mar 28, 2022

Okay, this seems to work.

@jtojnar jtojnar marked this pull request as ready for review March 28, 2022 12:02
@jtojnar jtojnar changed the base branch from staging-next to staging March 28, 2022 12:23
@jtojnar
Copy link
Contributor Author

jtojnar commented Mar 28, 2022

This can go to staging, since xterm is always available as a fallback.

@jtojnar jtojnar merged commit ca0b2cd into NixOS:staging Mar 29, 2022
@jtojnar jtojnar deleted the glib-gnome-console branch March 29, 2022 08:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants