View previous topic :: View next topic |
Author |
Message |
Troopo Guru
Joined: 14 Jun 2015 Posts: 310
|
Posted: Mon Sep 13, 2021 11:42 am Post subject: [SOLVED] KDE Plasma Xrandr after login |
|
|
Hi,
As the title states, i'm trying to run a few xrandr commands post login in plasma but for some reason it doesn't work.
I've tried kde autostart, autostart-scripts, cron job, .profile, .xinitrc, /etc/profile, sddm-scripts, and a few others but none worked.
Ideas?
Last edited by Troopo on Thu Sep 23, 2021 11:39 pm; edited 1 time in total |
|
Back to top |
|
|
psycho Guru
Joined: 22 Jun 2007 Posts: 534 Location: New Zealand
|
Posted: Mon Sep 13, 2021 12:28 pm Post subject: |
|
|
Hi.
Just to clarify, by "it doesn't work", do you mean that nothing happened when you put the instructions into an autostart script, but xrandr itself (when you type the instructions manually in a terminal window) does work as expected and produces the outcomes you're wanting to script? If so, have you confirmed that your autostart script is working at all (e.g. via touch ~/it_worked)...and if so, if you append e.g. 2>~/errors to the xrandr instructions can you see what's going wrong in that output? |
|
Back to top |
|
|
Anon-E-moose Watchman
Joined: 23 May 2008 Posts: 6103 Location: Dallas area
|
Posted: Mon Sep 13, 2021 6:10 pm Post subject: |
|
|
plasma-X11 or plasma-wayland??? It makes a difference _________________ PRIME x570-pro, 3700x, 6.1 zen kernel
gcc 13, profile 17.0 (custom bare multilib), openrc, wayland |
|
Back to top |
|
|
Troopo Guru
Joined: 14 Jun 2015 Posts: 310
|
Posted: Mon Sep 13, 2021 6:50 pm Post subject: |
|
|
psycho wrote: | Hi.
Just to clarify, by "it doesn't work", do you mean that nothing happened when you put the instructions into an autostart script, but xrandr itself (when you type the instructions manually in a terminal window) does work as expected and produces the outcomes you're wanting to script? If so, have you confirmed that your autostart script is working at all (e.g. via touch ~/it_worked)...and if so, if you append e.g. 2>~/errors to the xrandr instructions can you see what's going wrong in that output? |
Yes, nothing happened
Manually inputting command works
Manually running the shell file works too
I gave it permissions and have tried different things, the cron job said it ran ok but it runs after reboot, i needed it after login so cron didn't work out.
Regarding any errors, i didn't try so will update about that. |
|
Back to top |
|
|
Troopo Guru
Joined: 14 Jun 2015 Posts: 310
|
Posted: Mon Sep 13, 2021 6:51 pm Post subject: |
|
|
Anon-E-moose wrote: | plasma-X11 or plasma-wayland??? It makes a difference |
X11 |
|
Back to top |
|
|
Anon-E-moose Watchman
Joined: 23 May 2008 Posts: 6103 Location: Dallas area
|
Posted: Mon Sep 13, 2021 7:20 pm Post subject: |
|
|
Troopo wrote: | Anon-E-moose wrote: | plasma-X11 or plasma-wayland??? It makes a difference |
X11 |
What exactly are you trying to do? What is the xrandr command that the script is executing? And why are you using cron to run it? _________________ PRIME x570-pro, 3700x, 6.1 zen kernel
gcc 13, profile 17.0 (custom bare multilib), openrc, wayland |
|
Back to top |
|
|
Troopo Guru
Joined: 14 Jun 2015 Posts: 310
|
Posted: Mon Sep 13, 2021 10:05 pm Post subject: |
|
|
Anon-E-moose wrote: | Troopo wrote: | Anon-E-moose wrote: | plasma-X11 or plasma-wayland??? It makes a difference |
X11 |
What exactly are you trying to do? What is the xrandr command that the script is executing? And why are you using cron to run it? |
Xrandr is used to upscale the 2nd monitor from HD to 4K, otherwise i have 2 monitors with different resolutions.
I said i tried cron and it didn't work since it can't do it after login, but i also tried many other options including the basic KDE autostart-script and none worked.
Also no errors occurred. |
|
Back to top |
|
|
guyuming1 n00b
Joined: 18 Sep 2021 Posts: 5
|
Posted: Sat Sep 18, 2021 4:34 am Post subject: |
|
|
i used to put xrandr command in .xinitrc and start plasma with "startx" in tty .
the xrandr goes before startplasma-x11, and i might have chosen the added mode in plasma display settings for the first time.
Code: | gym@gymDeskGentoo ~ $ cat .xinitrc
xrandr --newmode "1920x1080_60.00" 173.00 1920 2048 2248 2576 1080 1083 1088 1120 -hsync +vsync
xrandr --addmode VGA-1 "1920x1080_60.00"
exec dbus-launch --exit-with-session startplasma-x11 |
now, i am using wayland, so xrandr don't work for me, so i build a file with edid_generator and pass it to kernel with the drm.edid_firmware kernel parameter: https://forums.gentoo.org/viewtopic-t-1142014-highlight-.html
although i had not tested, i think this solution also works for x11. |
|
Back to top |
|
|
Troopo Guru
Joined: 14 Jun 2015 Posts: 310
|
Posted: Sat Sep 18, 2021 10:09 am Post subject: |
|
|
guyuming1 wrote: | i used to put xrandr command in .xinitrc and start plasma with "startx" in tty .
the xrandr goes before startplasma-x11, and i might have chosen the added mode in plasma display settings for the first time.
Code: | gym@gymDeskGentoo ~ $ cat .xinitrc
xrandr --newmode "1920x1080_60.00" 173.00 1920 2048 2248 2576 1080 1083 1088 1120 -hsync +vsync
xrandr --addmode VGA-1 "1920x1080_60.00"
exec dbus-launch --exit-with-session startplasma-x11 |
now, i am using wayland, so xrandr don't work for me, so i build a file with edid_generator and pass it to kernel with the drm.edid_firmware kernel parameter: https://forums.gentoo.org/viewtopic-t-1142014-highlight-.html
although i had not tested, i think this solution also works for x11. |
Thanks for the reply.
I tried the generator but modeline2edid didn't find anything in my xorg, which is generated by nvidia settings and appears to have no modelines, it also doesn't have the 2nd monitor.
Not sure how to proceed from here, probably either set things manually or generate xorg using something else. |
|
Back to top |
|
|
guyuming1 n00b
Joined: 18 Sep 2021 Posts: 5
|
Posted: Sat Sep 18, 2021 11:51 am Post subject: |
|
|
Troopo wrote: |
I tried the generator but modeline2edid didn't find anything in my xorg, which is generated by nvidia settings and appears to have no modelines, |
you may get the modeline string with cvt: https://wiki.gentoo.org/wiki/Xrandr
Quote: |
To add a 75Hz mode, the tool cvt (x11-base/xorg-server) can be used to get a proper modeline:
user $cvt 1024x768 refresh 75
Everything after Modeline needs to be appended to the following command:
user $xrandr --newmode "1024x768_75.00" 109.00 1280 1368 1496 1712 1024 1027 1034 1063 -hsync +vsync |
But you cannot use the name such as "1024x768_75.00" in modeline2edid, which does not deal with charactor such as '.' well : https://github.com/akatrevorjay/edid-generator/issues/11
Since you use X11 instead of wayland, you don't need the modeline2edid tools to generator something for the kernel. just run xrandr with the string created by cvt to see whether it works. |
|
Back to top |
|
|
Troopo Guru
Joined: 14 Jun 2015 Posts: 310
|
Posted: Sat Sep 18, 2021 3:13 pm Post subject: |
|
|
guyuming1 wrote: | Troopo wrote: |
I tried the generator but modeline2edid didn't find anything in my xorg, which is generated by nvidia settings and appears to have no modelines, |
you may get the modeline string with cvt: https://wiki.gentoo.org/wiki/Xrandr
Quote: |
To add a 75Hz mode, the tool cvt (x11-base/xorg-server) can be used to get a proper modeline:
user $cvt 1024x768 refresh 75
Everything after Modeline needs to be appended to the following command:
user $xrandr --newmode "1024x768_75.00" 109.00 1280 1368 1496 1712 1024 1027 1034 1063 -hsync +vsync |
But you cannot use the name such as "1024x768_75.00" in modeline2edid, which does not deal with charactor such as '.' well : https://github.com/akatrevorjay/edid-generator/issues/11
Since you use X11 instead of wayland, you don't need the modeline2edid tools to generator something for the kernel. just run xrandr with the string created by cvt to see whether it works. |
I don't think CVT is part of (x11-base/xorg-server) anymore, i have it installed and it doesn't find the command. |
|
Back to top |
|
|
Troopo Guru
Joined: 14 Jun 2015 Posts: 310
|
Posted: Sun Sep 19, 2021 11:12 pm Post subject: |
|
|
Anyone else? |
|
Back to top |
|
|
MaDDeePee Guru
Joined: 18 Aug 2004 Posts: 387 Location: Germany
|
|
Back to top |
|
|
Troopo Guru
Joined: 14 Jun 2015 Posts: 310
|
Posted: Mon Sep 20, 2021 9:02 am Post subject: |
|
|
Yes i'm using sddm and yes i already have Xsetup being used since i have multiple displays but that only takes care of the login screen, my problem happens after i login, KDE somehow messes up the displays again and nothing i have tried made it run the same script...
But thanks anyway i appreciate any help. |
|
Back to top |
|
|
Troopo Guru
Joined: 14 Jun 2015 Posts: 310
|
Posted: Wed Sep 22, 2021 4:42 pm Post subject: |
|
|
I'm starting to believe the script runs after login but then is overwritten by some other setting, maybe from KDE.
Any ideas how to be sure? |
|
Back to top |
|
|
Ralphred Guru
Joined: 31 Dec 2013 Posts: 513
|
Posted: Wed Sep 22, 2021 6:01 pm Post subject: |
|
|
Disable the "kscreen 2" backend in system-settings>startup and shutdown>background services.
If this doesn't work have the command run in a terminal, set the title to something unique and wait for xdotool to be able to see the window of the terminal before it executes the xrandr commands. From here you should be able to get a good estimate for a simple sleep delay before your xrandr command by logging various stages of your script with timestamps. |
|
Back to top |
|
|
Troopo Guru
Joined: 14 Jun 2015 Posts: 310
|
Posted: Thu Sep 23, 2021 8:53 am Post subject: |
|
|
Ralphred wrote: | Disable the "kscreen 2" backend in system-settings>startup and shutdown>background services.
If this doesn't work have the command run in a terminal, set the title to something unique and wait for xdotool to be able to see the window of the terminal before it executes the xrandr commands. From here you should be able to get a good estimate for a simple sleep delay before your xrandr command by logging various stages of your script with timestamps. |
Disabling "kscreen 2" helped a bit, it's now close to what's needed by default but still not the same and doesn't run xrandr.
Regarding the second part of executing via terminal, where do i put the script for it to execute it? so far any place i tried didn't work... |
|
Back to top |
|
|
Ralphred Guru
Joined: 31 Dec 2013 Posts: 513
|
Posted: Thu Sep 23, 2021 5:31 pm Post subject: |
|
|
Troopo wrote: | where do i put the script for it to execute it? |
Best place is in ~/bin/ and make sure it's executable (chmod u+x ~/bin/myscript)
Once it runs from a command line as ~/bin/myscript and does what you expect, you can use system-settings>startup and shutdown>autostart to add it as an application*. This should create a myscript.desktop file in ~/.config/autostart/
*When I've added things as a login/logout-script using the autostart dialog, it does strange things (such as copying the script so when I update it, it still runs the "old" version) and they don't always work.
EDIT:If you get really stuck, you can use the system-settings>notifications and use the "run command" attached to a "plasma workspace" event, such as login or logout.
While you are still troubleshooting, including Code: | #!/bin/bash
date >> /home/username/myscript.log | will let you know if the script was actually run. Then you'll know if it's timing, command options, or a "not being run" problem. |
|
Back to top |
|
|
Anon-E-moose Watchman
Joined: 23 May 2008 Posts: 6103 Location: Dallas area
|
Posted: Thu Sep 23, 2021 5:58 pm Post subject: |
|
|
I believe that kscreen-doctor is the kde replacement for xrandr (kde-plasma/libkscreen), it should allow scripting like xrandr. _________________ PRIME x570-pro, 3700x, 6.1 zen kernel
gcc 13, profile 17.0 (custom bare multilib), openrc, wayland |
|
Back to top |
|
|
Troopo Guru
Joined: 14 Jun 2015 Posts: 310
|
Posted: Thu Sep 23, 2021 11:39 pm Post subject: |
|
|
Ralphred wrote: | Troopo wrote: | where do i put the script for it to execute it? |
Best place is in ~/bin/ and make sure it's executable (chmod u+x ~/bin/myscript)
Once it runs from a command line as ~/bin/myscript and does what you expect, you can use system-settings>startup and shutdown>autostart to add it as an application*. This should create a myscript.desktop file in ~/.config/autostart/
*When I've added things as a login/logout-script using the autostart dialog, it does strange things (such as copying the script so when I update it, it still runs the "old" version) and they don't always work.
EDIT:If you get really stuck, you can use the system-settings>notifications and use the "run command" attached to a "plasma workspace" event, such as login or logout.
While you are still troubleshooting, including Code: | #!/bin/bash
date >> /home/username/myscript.log | will let you know if the script was actually run. Then you'll know if it's timing, command options, or a "not being run" problem. |
This is very detailed, thank you!
Anon-E-moose wrote: | I believe that kscreen-doctor is the kde replacement for xrandr (kde-plasma/libkscreen), it should allow scripting like xrandr. |
I wasn't aware there was a kde replacement for xrandr, cool.
Finally got it to work properly, it was weird, i can't add script to autostart via GUI but if i add something to .config/autostart-scripts then it appears on the list in the GUI..
Anyway i check the command for that and somehow the path was /home/user/.config/old-autostart-scripts/script instead of /home/user/.config/autostart-scripts/script, no idea how old got there since i didn't create it.
After fixing that and possibly disabling "kscreen 2" also helped, it worked!
Thanks everyone, love this community. |
|
Back to top |
|
|
FrancaisDuQuebec n00b
Joined: 24 Mar 2024 Posts: 1
|
Posted: Sun Mar 24, 2024 10:59 am Post subject: Syntax error in command |
|
|
You had added the mode by copy/pasting the results of another command including the special character "
That character isn't processed when reading scripted commands.
To process it as text, you need to rwrite it like this
xrandr --output VGA-1 --mode \""1064x600_110.00\"" --scale 1.22x1.22
\\" = " |
|
Back to top |
|
|
|