alex-courtis / way-displays

way-displays: Auto Manage Your Wayland Displays
MIT License
240 stars 12 forks source link

Feature: Fall Back To Write Config Home #78

Closed xeruf closed 10 months ago

xeruf commented 1 year ago

Thank You for this awesome tool!

Apparently, the flag always tries to write globally:

❯ way-displays -w

Client sending request: write

Server received request: write

ERROR: Unable to write to /etc/way-displays/cfg.yaml: 13 Permission denied

Wrote configuration file: /etc/way-displays/cfg.yaml

I think it should check for write access (which it will mainly have when running as root) and otherwise use the local XDG dir - or, it the XDG variable is set, always prefer that.

Either way, it makes no sense to report success and an exit code of 0 after such an error.

alex-courtis commented 1 year ago

ERROR: Unable to write to /etc/way-displays/cfg.yaml: 13 Permission denied

That's not working as intended. way-displays should be writing to the configuration file that it read at startup.

The configuration file is found in order: File Locations resolving $XDG_... etc.

The actual file watched, read and written is the realpath of the file it finds i.e. follow symlinks etc.

What does it report to you on startup? e.g.

I [12:03:07] way-displays version 1.7.1
I [12:03:07]
I [12:03:07] Found configuration file: /home/alex/.dotfiles/config/way-displays/cfg.yaml

Alternatively, are you proposing that it writes to, say, $XDG_CONFIG_HOME/way-displays/cfg.yaml if there is no user configuration and /etc/way-displays/cfg.yaml has been defaulted to?

alex-courtis commented 1 year ago

Wrote configuration file: /etc/way-displays/cfg.yaml

That must be fixed.

alex-courtis commented 1 year ago

Either way, it makes no sense to report success and an exit code of 0 after such an error.

The return code is 2 after a write error, fixed by #72

alex-courtis commented 1 year ago

Config file:

Write active to:

  1. $XDG_CONFIG_HOME/way-displays/cfg.yaml
  2. $HOME/.config/way-displays/cfg.yaml

Directory creation is needed.

xeruf commented 1 year ago

sounds great, thank you :)

alex-courtis commented 10 months ago

This one took a while...

@xeruf I'd be most grateful if you could test this one:

git clone git@github.com:alex-courtis/way-displays.git
cd way-displays
git checkout 78-write-fallback-2
git submodule update --init
make
sudo make install

When you are done you can

sudo make uninstall
alex-courtis commented 10 months ago

Output should look something like:

I [16:54:46] way-displays version 1.8.2-SNAPSHOT
I [16:54:46]
I [16:54:46] Found configuration file: /home/alex/src/way-displays/78-write-fallback/wpcfg.yaml
I [16:54:46]
I [16:54:46] Active configuration:
I [16:54:46]   Arrange in a ROW aligned at the TOP
I [16:54:46]   Scaling: ON
I [16:54:46]   Auto scale: ON
I [16:54:47]
I [16:54:47] DP-1 Arrived:
I [16:54:47]   info:
I [16:54:47]     name:     'DP-1'
I [16:54:47]     make:     'GIGA-BYTE TECHNOLOGY CO., LTD.'
I [16:54:47]     model:    'Gigabyte M32Q'
I [16:54:47]     serial:   '0x0000064C'
I [16:54:47]     desc:     'GIGA-BYTE TECHNOLOGY CO., LTD. Gigabyte M32Q 0x0000064C (DP-1)'
I [16:54:47]     width:    700mm
I [16:54:47]     height:   390mm
I [16:54:47]     dpi:      93.34 @ 2560x1440
I [16:54:47]     mode:     2560 x 1440 @ 165 Hz  164,847 mHz (preferred)
I [16:54:47]     mode:     2560 x 1440 @ 144 Hz  143,999 mHz
I [16:54:47]     mode:     2560 x 1440 @ 120 Hz  119,998 mHz
I [16:54:47]     mode:     2560 x 1440 @  60 Hz   59,998 mHz
I [16:54:47]     mode:     1920 x 1200 @ 165 Hz  164,847 mHz
I [16:54:47]     mode:     1920 x 1080 @ 144 Hz  144,001 mHz
I [16:54:47]     mode:     1920 x 1080 @ 120 Hz  120,000 mHz 119,880 mHz
I [16:54:47]     mode:     1920 x 1080 @  60 Hz   60,000 mHz  60,000 mHz  59,940 mHz
I [16:54:47]     mode:     1920 x 1080 @  50 Hz   50,000 mHz
I [16:54:47]     mode:     1680 x 1050 @  60 Hz   59,954 mHz
I [16:54:47]     mode:     1600 x 1200 @ 165 Hz  164,847 mHz
I [16:54:47]     mode:     1440 x  900 @  60 Hz   59,887 mHz
I [16:54:47]     mode:     1440 x  576 @  50 Hz   50,000 mHz  50,000 mHz
I [16:54:47]     mode:     1440 x  480 @  60 Hz   60,000 mHz  60,000 mHz  59,940 mHz  59,940 mHz
I [16:54:47]     mode:     1280 x 1024 @  75 Hz   75,025 mHz
I [16:54:47]     mode:     1280 x 1024 @  60 Hz   60,020 mHz
I [16:54:47]     mode:     1280 x  960 @  60 Hz   60,000 mHz
I [16:54:47]     mode:     1280 x  800 @ 165 Hz  164,847 mHz
I [16:54:47]     mode:     1280 x  720 @ 120 Hz  120,000 mHz 119,880 mHz
I [16:54:47]     mode:     1280 x  720 @  60 Hz   60,000 mHz  60,000 mHz  59,940 mHz
I [16:54:47]     mode:     1280 x  720 @  50 Hz   50,000 mHz
I [16:54:47]     mode:     1152 x  864 @  75 Hz   75,000 mHz
I [16:54:47]     mode:     1024 x  768 @  75 Hz   75,029 mHz
I [16:54:47]     mode:     1024 x  768 @  70 Hz   70,069 mHz
I [16:54:47]     mode:     1024 x  768 @  60 Hz   60,004 mHz
I [16:54:47]     mode:      800 x  600 @  75 Hz   75,000 mHz
I [16:54:47]     mode:      800 x  600 @  72 Hz   72,188 mHz
I [16:54:47]     mode:      800 x  600 @  60 Hz   60,317 mHz
I [16:54:47]     mode:      800 x  600 @  56 Hz   56,250 mHz
I [16:54:47]     mode:      720 x  576 @  50 Hz   50,000 mHz  50,000 mHz
I [16:54:47]     mode:      720 x  480 @  60 Hz   60,000 mHz  60,000 mHz  59,940 mHz  59,940 mHz
I [16:54:47]     mode:      720 x  400 @  70 Hz   70,082 mHz
I [16:54:47]     mode:      640 x  480 @  75 Hz   75,000 mHz
I [16:54:47]     mode:      640 x  480 @  73 Hz   72,809 mHz
I [16:54:47]     mode:      640 x  480 @  67 Hz   66,667 mHz
I [16:54:47]     mode:      640 x  480 @  60 Hz   60,000 mHz  59,940 mHz  59,940 mHz
I [16:54:47]   current:
I [16:54:47]     scale:    1.000 (0.972)
I [16:54:47]     position: 0,0
I [16:54:47]     mode:     2560x1440@165Hz (164,847mHz) (preferred)
I [16:54:47]     VRR:      on
I [16:55:00]
I [16:55:00] Server received request: write
E [16:55:00]
E [16:55:00] ERROR: Unable to write to /home/alex/src/way-displays/78-write-fallback/wpcfg.yaml: 13 Permission denied
I [16:55:00]
I [16:55:00] Wrote configuration file: /home/alex/.config/way-displays/cfg.yaml
I [16:55:12]
I [16:55:12] Reloading configuration file: /home/alex/.config/way-displays/cfg.yaml
I [16:55:12]
I [16:55:12] New configuration:
I [16:55:12]   Arrange in a ROW aligned at the TOP
I [16:55:12]   Scaling: ON
I [16:55:12]   Auto scale: ON