Persistent resolution using xrandr in VNC - xrandr

I have Linux PC which is remote and boots up in text mode. I do access X on this machine via VNC.
However I do have requirement to resize the resolution ( different monitors ). I know xrandr is meant for this.
However whenever I add new mode using xrandr, it is not persistent across reboot. I see people mentioning a startup script sort of implementation for xrandr add-mode/new-mode, Is there any other way around.
I am aware of xorg.conf file, however it is support to work if X is started isn't it ?
On boot, xrandr shows couple of different resolutions, from where it does pick them ?

Created script and added in startup
To derive X params
gtf 1850 1150 60
To Add new Mode
xrandr --newmode "Name" <Output of Above Except Modeline "xxx_yyy_Hz" >
To Add mode into display
xrandr --addmode "VNC-0" "Name"
To set desired display
xrandr -s "Name"

Related

VS Code: How to unwrap output of a command in integrated terminal in linux

I use Ubuntu 18.4 and VS Code. I wanted to know how to unwrap output of a command in integrated terminal?
Is it possible? Also can it be done in Gnome terminal?
#Yedhin Answer Works, but I am unable to scroll horizontally. Which defeats the purpose of unwrapping.
I cant quite understand your use-case yet, but still the way I would read a long single line output would be by piping it to the less command :
my_command_which_produces_long_output | less -S
you can do the same in your terminal emulator as well with the less command.
Edit : I don't know for sure why horizontal scrolling doesn't work with gnome-terminal. For me it works fine with the command less -S. But you can try explicitly setting scrolling by running these commands from your terminal and see if either of them gives your desired results.
gsettings set org.gnome.settings-daemon.peripherals.touchpad horiz-scroll-enabled "true"
synclient HorizTwoFingerScroll=1
If these don't work either, then i strongly suggest you to try out dconf editor and to enable horizontal scroll in the touchpad section in it. If that too is fruitless, then change your terminal emulator something better like:
lightweight : st
fast : alacritty
more gui options : konsole/tilix
Hope this helps. Cheers!

Windows: Switch between Display Settings (3 or more Displays)

How can i switch (respectively save and restore) between display settings.
All ways i found works only with two displays. But i have four connected.
Is there a way to chang it with comandline tools e.g. PowerShell.
For example,
in one configuration I want to stretch the desktop over three screens, the fourth duplicates the first screen or is disabled.
Or the desktop is only cloned on two and the others are disabled.
NirSoft MultiMonitorTool has command line support for a variety of monitor related functions...
eg. Disable Monitor 1 and Enable Monitor 3:
MultiMonitorTool.exe /disable 1
MultiMonitorTool.exe /enable 3
You can also save and load specific configurations:
MultiMonitorTool.exe /SaveConfig "c:\temp\monitors1.cfg"
MultiMonitorTool.exe /LoadConfig "c:\temp\monitors1.cfg"

How to script to turn off mac window mirroring,

So I have 150+ users who are using a mac mini, El Capitan.
I use deploy studio to make an image so I can clean out the junk every so often, on this image I have settings and such that I can regulate, I am not sure how to make it so the first time someone logs in, the windows are not mirrored, (everyone is using dual monitors). Is this possible?
I can make an Apple script to do it just fine, but that isn't acceptable in this case.
Question : How do I set the preference/setting of "mirror windows" to be automatically or always unchecked?
maybe this link could help your problem : https://discussions.apple.com/thread/2750766?tstart=0
The setting for whether a display is mirrored or not is controlled per display using the key "Mirrored" in this file:
/Library/Preferences/com.apple.windowserver.plist
However, that file contains a list of displays, each potentially with a unique identifier. You might be able to lay down the same file on multiple machines provided they all have the same monitor model, but I don't know for sure.

Disable ambient-light sensor screen dimming programmatically on OS X

I've been digging around in the kernel code repo for days, but I just can't find this anywhere.
I want to disable/enable/detect the state of the ambient-light sensor based screen dimming that many of the higher end Mac laptops have. This is the dimming that is activated by the "Automatically Adjust Brightness" checkbox in the Display control panel.
Note that I'm NOT talking about the halfdim setting that causes the screen to dramatically dim right before it sleeps. I'm talking about the setting that dims the screen in dark rooms and brightens it in light rooms, which is different.
If anybody can even point me in the right direction I'd be greatfull. I assume it's handled somewhere in IOKit, probably either IOGraphics where screen brightness is handled, or somewhere in IOKit/pwr_mgt, but I just can't find it.
Thanks
Edit: I know you can kind of do this this by addressing System Preferences with AppleScript. I'm looking for the real way, if it exists.
This isn't an API, per sé.. but there are many ways to control launchd via an API.
sudo launchctl stop com.apple.AmbientDisplayAgent
sudo launchctl remove com.apple.AmbientDisplayAgent
Ta Da!
Trying to do this on Mavericks was unsuccessful for me. After some research I've discovered you need to use the following command:
defaults write /Library/Preferences/com.apple.iokit.AmbientLightSensor "Automatic Display Enabled" -bool TRUE
I believe specifying the full path is necessary else it would default to the user's Library/Preferences which is incorrect. Being in that directory in Terminal doesn't work either due to the way defaults works.
This does not update the tickbox in System Preferences -> Displays though.
Change the "Automatically Adjust Brightness" setting using the defaults command:
defaults write com.apple.BezelServices dAuto -boolean false
Also retrieve the current setting using the defaults command:
defaults read com.apple.BezelServices dAuto
AppleScript equivalent:
do shell script "defaults write com.apple.BezelServices dAuto -boolean false"
Use true to enable and false to disable the feature.
You might need to logon again for the changes to take effect.
Posting this as it might help someone who like me had already disabled the ambient light sensing but still found their computer was dimming when waking from sleep. Turns out I also needed uncheck the box to "Slightly dim the display while on battery power"
System Preferences > Battery > Slightly dim the display while on battery power
See the image below:

GTK: How to ignore "can't open display" errors?

I have written some GTK programs using the gtkD bindings for the D programming language that are otherwise console apps, but are capable of displaying plots on the screen and saving them to a file. I'd like to run these on a machine that I only have console-based SSH access to, which means that the plots wouldn't be displayed on the screen, but would still be written to files.
When I call Main.init(), I get a Gtk-WARNING **: cannot open display, as expected. When I call Main.initCheck() instead and ignore the errors, I simply get more errors later in execution related to the lack of a screen.
Is there some easy way to make my program ignore the fact that there's no screen available, do all its on-screen drawing to some dummy device (the graphics equivalent of /dev/null) and still actually draw to Pixmaps and Pixbufs (necessary for saving plots to files) and run the non-GUI-based parts of the app?
Edits: In cases where the app launches a window and blocks on an event loop, the ideal thing to do would be to close the window immediately (or not succeed in opening it in the first place) and continue running the non-GUI based parts of the program. If this is impossible I can work around it by making sure I don't launch any windows.
Also, it appears that Pixbufs and Pixmaps don't work without a screen present. I tried drawing to a Pixmap, creating a Pixbuf out of that, and saving the results to a file, either after calling Main.checkInit() and ignoring the errors or without an init statement and either way GTK complains about lack of a screen.
I believe the simplest solution is to use only GdkPixbufs for processing your plots; as far as I know, the gdk-pixbuf library only deals with pixbufs in memory and doesn't need a window system. Keep the processing and display parts of your code strictly separated. If you do that, it shouldn't matter that there is no screen. You could even make a command-line option to disable drawing to the screen.
You could also use GtkOffscreenWindow but this has only been available since GTK 2.20 and as far as I can tell the D bindings only cover up to 2.18.
Alternatively, you could use X forwarding in your SSH session; use -X or -Y on your SSH command line. See your SSH manual for more information. If you are running an X server on the machine you are SSH'ing from, then the plots can be displayed on your local machine's screen.
Pixmaps won't work without server - they are, by definition (in X terminology), image resources stored on X server. Pixbufs, however, are stored in client application, and they should work without X.
If you need Pixmaps but don't want to graphics, you have two choices:
Enable SSH X tunneling by passing -X flag. In this case, your app will be able to use local X server.
Use Xvfb - it's dummy X server that does no output at all, and all graphics are stored in memory.

Resources