Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[SOLVED] KDE Plasma Xrandr after login
View unanswered posts
View posts from last 24 hours
View posts from last 7 days

 
Reply to topic    Gentoo Forums Forum Index Desktop Environments
View previous topic :: View next topic  
Author Message
Troopo
Guru
Guru


Joined: 14 Jun 2015
Posts: 310

PostPosted: Mon Sep 13, 2021 11:42 am    Post subject: [SOLVED] KDE Plasma Xrandr after login Reply with quote

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
View user's profile Send private message
psycho
Guru
Guru


Joined: 22 Jun 2007
Posts: 534
Location: New Zealand

PostPosted: Mon Sep 13, 2021 12:28 pm    Post subject: Reply with quote

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
View user's profile Send private message
Anon-E-moose
Watchman
Watchman


Joined: 23 May 2008
Posts: 6098
Location: Dallas area

PostPosted: Mon Sep 13, 2021 6:10 pm    Post subject: Reply with quote

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
View user's profile Send private message
Troopo
Guru
Guru


Joined: 14 Jun 2015
Posts: 310

PostPosted: Mon Sep 13, 2021 6:50 pm    Post subject: Reply with quote

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
View user's profile Send private message
Troopo
Guru
Guru


Joined: 14 Jun 2015
Posts: 310

PostPosted: Mon Sep 13, 2021 6:51 pm    Post subject: Reply with quote

Anon-E-moose wrote:
plasma-X11 or plasma-wayland??? It makes a difference


X11
Back to top
View user's profile Send private message
Anon-E-moose
Watchman
Watchman


Joined: 23 May 2008
Posts: 6098
Location: Dallas area

PostPosted: Mon Sep 13, 2021 7:20 pm    Post subject: Reply with quote

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
View user's profile Send private message
Troopo
Guru
Guru


Joined: 14 Jun 2015
Posts: 310

PostPosted: Mon Sep 13, 2021 10:05 pm    Post subject: Reply with quote

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
View user's profile Send private message
guyuming1
n00b
n00b


Joined: 18 Sep 2021
Posts: 5

PostPosted: Sat Sep 18, 2021 4:34 am    Post subject: Reply with quote

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
View user's profile Send private message
Troopo
Guru
Guru


Joined: 14 Jun 2015
Posts: 310

PostPosted: Sat Sep 18, 2021 10:09 am    Post subject: Reply with quote

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
View user's profile Send private message
guyuming1
n00b
n00b


Joined: 18 Sep 2021
Posts: 5

PostPosted: Sat Sep 18, 2021 11:51 am    Post subject: Reply with quote

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
View user's profile Send private message
Troopo
Guru
Guru


Joined: 14 Jun 2015
Posts: 310

PostPosted: Sat Sep 18, 2021 3:13 pm    Post subject: Reply with quote

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
View user's profile Send private message
Troopo
Guru
Guru


Joined: 14 Jun 2015
Posts: 310

PostPosted: Sun Sep 19, 2021 11:12 pm    Post subject: Reply with quote

Anyone else?
Back to top
View user's profile Send private message
MaDDeePee
Guru
Guru


Joined: 18 Aug 2004
Posts: 387
Location: Germany

PostPosted: Mon Sep 20, 2021 3:51 am    Post subject: Reply with quote

Troopo wrote:
Anyone else?


Are you using sddm as login manager?

https://blog.victormendonca.com/2018/06/29/how-to-fix-sddm-on-multiple-screens/

Check this, i am using xrandr like described here to fix the posion of my screens. just alter the --mode ?

/usr/share/sddm/scripts/Xsetup

good luck :)
Back to top
View user's profile Send private message
Troopo
Guru
Guru


Joined: 14 Jun 2015
Posts: 310

PostPosted: Mon Sep 20, 2021 9:02 am    Post subject: Reply with quote

MaDDeePee wrote:
Troopo wrote:
Anyone else?


Are you using sddm as login manager?

https://blog.victormendonca.com/2018/06/29/how-to-fix-sddm-on-multiple-screens/

Check this, i am using xrandr like described here to fix the posion of my screens. just alter the --mode ?

/usr/share/sddm/scripts/Xsetup

good luck :)


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
View user's profile Send private message
Troopo
Guru
Guru


Joined: 14 Jun 2015
Posts: 310

PostPosted: Wed Sep 22, 2021 4:42 pm    Post subject: Reply with quote

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
View user's profile Send private message
Ralphred
Guru
Guru


Joined: 31 Dec 2013
Posts: 499

PostPosted: Wed Sep 22, 2021 6:01 pm    Post subject: Reply with quote

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
View user's profile Send private message
Troopo
Guru
Guru


Joined: 14 Jun 2015
Posts: 310

PostPosted: Thu Sep 23, 2021 8:53 am    Post subject: Reply with quote

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
View user's profile Send private message
Ralphred
Guru
Guru


Joined: 31 Dec 2013
Posts: 499

PostPosted: Thu Sep 23, 2021 5:31 pm    Post subject: Reply with quote

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
View user's profile Send private message
Anon-E-moose
Watchman
Watchman


Joined: 23 May 2008
Posts: 6098
Location: Dallas area

PostPosted: Thu Sep 23, 2021 5:58 pm    Post subject: Reply with quote

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
View user's profile Send private message
Troopo
Guru
Guru


Joined: 14 Jun 2015
Posts: 310

PostPosted: Thu Sep 23, 2021 11:39 pm    Post subject: Reply with quote

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
View user's profile Send private message
FrancaisDuQuebec
n00b
n00b


Joined: 24 Mar 2024
Posts: 1

PostPosted: Sun Mar 24, 2024 10:59 am    Post subject: Syntax error in command Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Desktop Environments All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum