foreshadow / atom-python-run

A simple atom package. Press one key to run your python code in atom.
https://atom.io/packages/atom-python-run
MIT License
44 stars 32 forks source link

gnome-terminal gets pushed to background #70

Open ghost opened 6 years ago

ghost commented 6 years ago

Hi! I am running atom 1.22.0 on Ubuntu 17.10. If I launch atom-python-run with the terminal specified as gnome-terminal, gnome-terminal launches on the background. I'd like the terminal to pop up in the foreground, like xterm (or terminator).

ghost commented 6 years ago

Ubuntu 17.10 moved away from Unity and reverted back to Gnome. Gnome now uses version 3 by default and so does 17.10. I happen to use Archlinux with gnome3 and have the same issue, although, it's not neccessarily related to this plug-in.

It has to do with the shell and how certain windows in the evironment are focused. MS Windows is the only OS that seems to allow the terminal to take focus by default while Mac OS X and Gnome3 seem to push it to background.

xterm works for me as well and places itself in the foreground automatically. Not sure if any other systems/terminals have this issue as well. Let me know if you figure it out. You can always create a fork, pull request, or post a fix here.

In short, I don't know how to change/fix it and I'm open to proactive solutions.

wickedjargon commented 6 years ago

How do you get Ubuntu to use xterm instead? I tried typing in 'xterm' in the Terminal field in settings but this didn't change anything.

ghost commented 6 years ago

The terminal field behaves like a list which takes the terminal name and the execution option. If you're using unity, you should be okay.

make sure xterm is installed (it usually is by default in ubuntu)

If it's installed, you'll see it in the results. If not, you'll have to install it.

In Atom, go to settings -> atom-python-run -> settings -> terminal i.e. xterm, -e

That's all there is to it.

ghost commented 6 years ago

@FredhRodrigues -- README -- #69

Terminal opening in background (Ubuntu 16) #73

Hello guys. I was using everything without a problem, then I don't know if I hit the wrong key or changed the wrong lines in config.cson but now this started to happen. At first I thought f5 was not working anymore then I saw a dozen terminal windows in the back.

This is really annoying. Is there anyway to make it open in the foreground again? Thanks in advance.

Even though issue #73 takes place in Ubuntu 16.xx, which I find interesting because it uses Unity as its WM and DE, it can be cataloged here since it resembles this issue, #70. Issue #73 will be merged with issue #70 to help isolate this general issue.

FredhRodrigues commented 6 years ago

I was not sure where to post it since it was in a different version of Ubuntu so I figured it would be best to start a new thread. I did check issue 70 before posting and I can use xterm but that doesn't explain why this started to happen to terminal so suddenly.

ghost commented 6 years ago

@FredhRodrigues Both Unity and Gnome use gnome-terminal as their default terminal. So it's okay. Hopefully, someone can help figure it out. I still don't have a solution. If one is resolved, the other may not be, and that would allow some focus to remain on that issue. It might even give a hint or a clue that could help resolve it.

FredhRodrigues commented 6 years ago

Reinstalling Atom (purge and install) seemed to have solved the problem, everything is working fine now. Thanks for the help!

ghost commented 6 years ago

So far this seems to be an issue related to Gnome and Quartz Desktop Environments.

No other users (that I know of) have provided information about other Desktop Environments issues.

I stumbled upon some good news today while browsing my reddit feed today.

I followed one of the links provided in the comments to a unix.stackexchange post.

One of the answers provided mentions a utility named wmctrl so I looked it up since I wasn't familiar with it. Turns out this is really just a fortunate happenstance.

It seems like this can be installed fairly easily... Obviously you want to do it according to your distribution.

ubuntu example

sudo apt update
sudo apt install wmctrl -y

archlinux example

sudo pacman -S wmctrl

You get the point. What I could do is write up a small patch to handle gnome specifically seeing as that's what I can apply this to.

The idea would be to probably use a wrapper to call the CLI to grab information... Once the Terminal has been instantiated, you can make a secondary call to wmctrl to focus the terminal window automatically instead of relying on notifications or using super + tab to cycle to the terminal.

an example call after terminal has been opened would be

wmctrl -a terminal

I'm sure there are other, better, ways (like the API)... but this is just me playing around with an idea for now. Also leaving this as a note for my future self (as well as others interested in a fix).