Linux - DesktopThis forum is for the discussion of all Linux Software used in a desktop context.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Two ways. Either put appropriate xrandr command in your autostart actions (for example "xrandr --mode 1600x900"). Test the command to make sure it works before adding it. https://wiki.archlinux.org/title/Xfce#Autostart
Or you could install virtualbox guest extensions, then set resolution from virtualbox menu. To install those, select the 'insert guest additions' cd option, then open the CD and run the VBoxLinux... script.
It works for me without guest additions or convoluted cron/systemd commands (why not just use a systemd timer instead? But I digress....).
Just set up display resolution with common GUI tools in the guest OS, should get applied at login, and that should be enough.
Which distro, which desktop environment?
To answer your question about cron, since it is not automatically associated with the desktop so its like trying to run a GUI application without a GUI. To associate cron with the desktop you need to specify the display environment variable like:
Depending on distribution and cron version I should of added the full path to xrandr but check on your system.
@reboot DISPLAY=:0 /usr/bin/xrandr -s 1600x1200
As suggested above I would add guest additions. Depending on distribution/version you might need to install extra stuff like gcc and the source header files before you can actually install them.
xrandr -s 1600x1200 is valid. I tried it in the cli and it worked. Why do you consider this as inappropriate?
Sorry I didnt mean that it was invalid. I just meant use xfce autostart for any xrandr command that works, using one of those methods I linked earlier...
Quote:
To launch custom applications when Xfce starts up, click the Applications Menu > Settings > Settings Manager and then choose the Session and Startup option and click the tab Application Autostart. You will see a list of programs that get launched on startup. To add an entry, click the Add button and fill out the form, specifying the path to an executable you want to run.
Autostart applications are stored as name.desktop in ~/.config/autostart/.
Alternatively, add the commands you wish to run (including setting environment variables) to xinitrc (or xprofile when a display manager is being used).
Tip: Sometimes it might be useful to delay the startup of an application. Note that specifying under Application > Autostart a command such as sleep 3 && command does not work; a workaround is to use the syntax sh -c "sleep 3 && command"
Quote:
Originally Posted by A-Okay
Okay. I'll try to do the settings over Virtualbox.
If you install the guest additions on guest OS, then you can select resolution from Virtual Box menu under View/Virtual Screen (which it remembers thru shutdowns and reboots, etc) for that machine. If you have hidden your menu bar, hit Ctrl+Home to get popup menu.
My experience with VirtualBox has been that, once I set the display in a VMs system settings, the VM has retained the setting.
One thought that comes to me is that, in the VirtualBox display settings for that VM (not the display settings within the VM), perhaps experimenting with the "Graphics Controller" setting might yield some results.
When I reboot the system, I have to change the screen resolution over the settings each time.
How could I set the screen resolution value, fix it, so I don't need to do change it everytime by doing it manually?
This is actually a file persistence issue. It might indicate something else is wrong with the VM.
@frankbell
Quote:
My experience with VirtualBox has been that, once I set the display in a VMs system settings, the VM has retained the setting.
Quote:
I had an idea but it doesn't work. What I did:
crontab -e
@reboot /usr/bin/xrandr -s 1600x1200
sudo systemctl enable cron.service
sudo nano /etc/cron.allow (put the user into it)
reboot
But after rebooting the OS it doesn't change.
Anymore ideas or am I doing smth. wrong with cron?
The cron.service runs before graphical.target has even started X and the GUI. xrandr can't change the resolution of a screen that hasn't been created yet as X itself hasn't been started.
The cron.service runs at multi-user.target (old runlevel 3) while X and the DE are started at graphical.target (old runlevel 5).
It is simplest to use the DE autostart directory.
Last edited by tofino_surfer; 09-03-2021 at 01:39 AM.
This is a poor choice of location for a personally created script. In most distros, /usr/bin/ should be the exclusive domain of the package management system. Anything you place there is subject to being overwritten by package management activity. Scripts you create for global use are better placed in /usr/local/bin/ or /usr/local/sbin/.
Xrandr scripts will be run automatically if you place them in an appropriate location in /etc/X11/. The appropriate location depends on the distro. e.g. in Debian and derivatives, /etc/X11/Xsession.d/ usually works.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.