i3 wm: start my application on a specific screen and give it focus & move the mouse there - window

I have searched several forums and I always find partial answers, but none that seem to solve my issue.
I am developing my own game on a desktop PC (BTW. I use Arch ;-)) with two screens and the i3 window manager. I develop on the right (square 1:1) screen and I would like to open my game on the left (16:9) screen after compilation. I can simulate this by always moving my mouse to the left screen during compilation so that the game opens there, but then I need to have an empty workspace open to move to.
I can find solutions to be put in the i3-config file where I can specifically open a window with a specific class name on a specific workspace (which is not necessarily a specific monitor) and I can certainly not give it focus after that.
I would love to be able to do it just with command line commands: I develop in vim and have a hotkey that starts my make&run script. The script will run the application when there are no compiler errors. It would be great if that command could be extended with "and also put it on the left monitor in an empty workspace and give it focus, also by moving the mouse there".
A solid i3-config solution would also be ok, maybe even better because I don't need the functionality on my laptop.
I wouldn't mind reserving a specific workspace for my game if needed.

I can find solutions to be put in the i3-config file where I can specifically open a window with a specific class name on a specific workspace (which is not necessarily a specific monitor) and I can certainly not (sic?) give it focus after that.
(note: is the "not" a typo here? I am a little confused).
As far as a solution with a config file is concerned, you are already half way there. The only thing you need to do is to have that workspace on the monitor of your choice.
Here is a full solution (with config file), including the steps you already solved:
1. Dedicate a workspace for your game
Since you can create as many workspaces as you want, there is no downside to this.
assign [class="MyGame"] game
2. Assign this workspace to your left screen
First, you need to know the name of the screen with xrandr (xorg-xrandr package on Arch).
Here is an example output in my settings:
$ xrandr
Screen 0: minimum 8 x 8, current 2560 x 2520, maximum 32767 x 32767
eDP1 connected primary 1920x1080+0+1440 (normal left inverted right x axis y axis) 310mm x 170mm
1920x1080 60.00*+ 59.93 48.00
1680x1050 59.95 59.88
1400x1050 59.98
1600x900 60.00 59.95 59.82
1280x1024 60.02
1400x900 59.96 59.88
1280x960 60.00
1368x768 60.00 59.88 59.85
1280x800 59.81 59.91
1280x720 59.86 60.00 59.74
1024x768 60.00
1024x576 60.00 59.90 59.82
960x540 60.00 59.63 59.82
800x600 60.32 56.25
864x486 60.00 59.92 59.57
640x480 59.94
720x405 59.51 60.00 58.99
640x360 59.84 59.32 60.00
DP1 disconnected (normal left inverted right x axis y axis)
DP2 connected 2560x1440+0+0 (normal left inverted right x axis y axis) 550mm x 310mm
2560x1440 59.95*+
2048x1080 60.00 24.00
1920x1080 60.00 50.00 59.94
1920x1080i 60.00 50.00 59.94
1600x1200 60.00
1280x1024 75.02 60.02
1152x864 75.00
1280x720 60.00 50.00 59.94
1024x768 75.03 60.00
800x600 75.00 60.32
720x576 50.00
720x480 60.00 59.94
640x480 75.00 60.00 59.94
720x400 70.08
HDMI1 disconnected (normal left inverted right x axis y axis)
HDMI2 disconnected (normal left inverted right x axis y axis)
VIRTUAL1 disconnected (normal left inverted right x axis y axis)
In my case, eDP1 is my primary (laptop) monitor and DP2 is my external monitor.
If I wanted the workspace game on my external monitor, I would use:
workspace game output DP2
3. Create a keybinding that will run your "make&run script" and move the focus and the mouse to your game workspace
bindsym <my-bind> exec --no-startup-id <make&run script>; workspace game
Instead of using your vim hotkey, you are using an i3 keybinding to both run the script (which will open the application and the application will open in the correct monitor thanks to the settings above) and move the focus to that monitor:
It is easy to have i3 execute commands while it is very hard to have a command move the mouse and focus around (since this is the task of a wm or desktop environment).
I can think of a downside of this method:
When you hit a compiler error, your focus and mouse will still jump to your left monitor. You might find this annoying if it happens often.
The way I go about jumping from workspace to workspace is that I have a list of named workspaces and easy mnemonic keybindings to get to them.
So I would handle this a little differently than have one keybinding (or command as you had asked) doing the whole thing:
I would have a workspace with a bunch of applications I always want on my left monitor
assign [class="MyGame"] workspaceleft
assign [class="App1"] workspaceleft
assign [class="App2"] workspaceleft
assign [class="App3"] workspaceleft
workspace workspaceleft output <left-monitor-name-given-by-xrandr>
workspace workspacevim output <right-monitor-name-given-by-xrandr>
and I would have an easy keybinding to go to that workspace (and others to go to my other workspaces. So I would also have keybindings to go back to the or , depending on whether you'd rather have one application per workspace or only one workspace per monitor, etc.)
bindsym <bind1> workspaceleft
bindsym <bind2> workspacevim
So I would work in vim and use the vim hotkey. If compilation works, the game would land in the proper monitor thanks to our early settings. I would then press <bind1> to get to it (and <bind2> to come back to the right-hand side monitor when I want to).
I think that this may be more convenient than the do-the-whole-thing keybinding.
Plus, being able to jump to any application by a key press and have all my applications land by default where I want to and the way I want to is one of the things I really love about i3. So setting such things might make your workflow a lot nicer beside this particular application.
Alternatively, you can have a keybinding to toggle between your monitors:
bindsym <bind> focus output left
(Note that here "left" is not a workspace name but the direction. This will toggle between monitors set next to each other. Replace "left" with "up" if they are on top of each other).

Related

Microsoft Teams: video meeting window is HUGE on a 4K monitor. Any fixes, including registry settings?

I use a cheap 55" 4K TV as an external monitor over HDMI (laptop screen is too small).
Most programs are all good, and this is like having 4 22" monitors on my desk so I can keep a lot of files open.
However, one program is a problem - when I join MS teams meetings, they are in a separate window as expected. However, the video window always opens at about 38 inches (diagonal) on my 55" monitor, so multiple times per day I have to resize and reposition at the start of a meeting.
There are no apparent settings in teams (the zoom setting has no effect on the size of the new video window). Teams does not save the size/position of the last video window from the last meeting.
Are there any other hidden settings, or maybe a registry key that defines either the absolute size of the new video window, or the percentage of the screen it should fill when opening?
Thank you!

DPI Scaling on NixOS with LightDM + XMonad

I've stripped the xserver configuration on my HiDPI laptop down to just:
displayManager: lightdm (autologin, no greeter)
windowManager: xmonad
desktopManager: none (xterm disabled)
And everything is working fine apart from DPI scaling in some places. Specifically: the cursor size and default tty font are both tiny. Apps - terminal emulators, Firefox, etc - are scaling fine as a result of my X settings (below).
Cursor size, and the slow movement that results, is the biggest pain.
So my question is: why would I see proper scaling in some places and not others? What is responsible for the cursor size and other "core" display stuff?
Stuff I've done/tried:
✓ services.xserver.dpi = 180; (sets xserver flag)
✓ .Xresources settings
Xft.dpi: 180
Xft.autohint: 0
Xft.lcdfilter: lcddefault
Xft.hintstyle: hintfull
Xft.hinting: 1
Xft.antialias: 1
Xft.rgba: rgb
✓ export GDK_SCALE=2
✓ export GDK_DPI_SCALE=0.5
✓ export XCURSOR_SIZE=32
✓ export QT_AUTO_SCREEN_SCALE_FACTOR=1
Relevant (?) GH issues:
nixpkgs#22652
Using NixOS 18.03
Having struggled with this for a while, here are my conclusions...
Whatever black magic is at play making the mouse pointer do it's thing, it has no concern for DPI. In retrospect this seems kinda obvious. A mouse pointer moving across a screen is "lower-level" than a GUI application, such that DPI per se is irrelevant.
The fix? Bigger pointer icon (64x64 worked for me) and more sensitive movement (libinput Accel Speed in my case).

Understanding multi monitor dpi

On Windows 8.1 I created a firefox addon to take a screenshot.
I'm having an issue. This is what I'm doing:
I have a setup like this (mon1 is not primary monitor, has res of 1920x1080, monitor 2 is primary and has res of 1280x1024)
Screenshot all monitors to ImageData.
Open two featureless/borderless windows with this code:
Then after window opens I move it to the originX and originY of each monitor then make it fullscreen:
aEditorDOMWindow.moveTo(colMon[iMon].x, colMon[iMon].y);
aEditorDOMWindow.focus();
aEditorDOMWindow.fullScreen = true;
Then I create a canvas with width x height matching screen resolution in each window and draw to it the monitors screenshot
So now the problem is, the windows open on monitor 2, then when i move it to monitor 1 and inspect canvas, the size is 1920x1080 which matches the resolution, but in the video recording below I measured it with photoshop and it visually is actually 2880 x 1620.
Here is a youtube screencast demonstrating it:
Youtube :: Why other monitor almost double size?
I always notice as I drag a window from one monitor to another it slightly changes size, what is this called? Is it specific to Window8.1+? Is there anyway with WinAPI I can trigger this resize?
You no doubt see the DPI virtualization feature of Windows at work. Nothing you can do about it in this case, it is up to the main application to declare itself multi-monitor DPI aware.
It doesn't, the subject of Mozilla bug #890156. Two years old already, they are not in a hurry to fix it. Not a lot of votes, you can add one.

How to use xmonad in portrait mode/orientation?

How does one use xmonad with the physical screens in portrait orientation?
I have two physical displays and they are both rotated 90 degrees to the right (clockwise with original bottom edges on the left)
I'm on Fedora 21 (3.19.3-200.fc21.x86_64)
I don't know how to tell what window manager is running, but there's a gnome-shell process running...
When I sudo telinit 3 and then startx, xmonad comes up with everything in landscape orientation. I don't know how to change it at that point and I don't know how to make it start in portrait mode.
My .xinitrc file says this
#!/usr/bin/env bash
emacs &
gnome-terminal &
exec xmonad
Thanks in advance for any help!
Well, first of all, your window manager seems to be xmonad ;-).
Independent of that, xrandr does what you need.
Shamelessly taken from here (because SO doesn't accept duplicates from unix.stackexchange.com):
Find your output devices with xrandr (the first word before "connected", you should find two such lines), e.g. eDP1 if the output is
eDP1 connected 1600x900+0+0 (normal left inverted right x axis y axis) 309mm x 174mm
and then have fun with
xrandr --output eDP1 --rotate right
in your .xinitrc.
The original answer notices that by using a NVidia card you may have to add
Option "RandRRotation" "True"
to your xorg.conf (which i cannot verify with my setup).

OSX Applescript/Automator action to trim + untrim videos in iPhoto

Can Applescript or Automator do specific repeatable steps within OS X apps, specifically iPhoto? If so, i'd love to see some examples!
I want to do the "fix" described in the link below on hundreds of video files in an iPhoto library: how-to-trim-and-share-video-in-iphoto-tutorial
In a nutshell, to get around a problem where iPhoto video thumbnails show up as black (and the built in "rebuild thumbnails" command fails) one can do the following steps to force iPhoto to regenerate a new "correct" (not black) thumbnail:
1) Open Video
2) Video Options (little gear icon) -> Trim
3) Trim left .1 second (this forces iPhoto to regen a thumbnail)
4) Video Options -> Reset Trim
These steps solve the problem but are very time consuming, so if there's a way to automate the steps above, i would be forever grateful to know how!

Resources