efernau / rot8

screen rotation daemon
MIT License
109 stars 27 forks source link

How to run rot8 on startup? (sway) #44

Open realestninja opened 1 year ago

realestninja commented 1 year ago

Hi,

rot8 is working for me, when I try it manually from the terminal. Now I want to add it to my startup, so it will be running in the background after I log into sway.

I have a working sway config and I am just adding these lines for rot8:

# autorotate
exec swaymsg "input 1386:21173:Wacom_HID_52B5_Finger map_to_output eDP-1"
exec rot8

The swaymsg from that codeblock is being executed. (If I run rot8 manually, then the touchscreen will be mapped correctly). However rot8 is not being started. When I check my list of processes, rot8 is not there.

Any ideas? Let me know if you have a suggestion on how I can debug my sway startup.

efernau commented 1 year ago

Normally it should be fine if you put something like exec rot8 --display eDP-1 in your sway config.

realestninja commented 1 year ago

When I run sway -d (debug mode) the log for those lines looks like this:

00:00:00.456 [sway/commands.c:260] Handling command 'exec swaymsg "input 1386:21173:Wa
com_HID_52B5_Finger map_to_output eDP-1"'
00:00:00.456 [sway/commands/exec_always.c:59] Executing swaymsg "input 1386:21173:Waco
m_HID_52B5_Finger map_to_output eDP-1"
00:00:00.461 [sway/commands/exec_always.c:112] Child process created with pid 1112567
00:00:00.461 [sway/commands/exec_always.c:114] Recording workspace for process 1112567
00:00:00.462 [sway/commands.c:260] Handling command 'exec rot8'
00:00:00.462 [sway/commands/exec_always.c:59] Executing rot8
00:00:00.467 [sway/commands/exec_always.c:112] Child process created with pid 1112575
00:00:00.467 [sway/commands/exec_always.c:114] Recording workspace for process 1112575

But when I check for the pid of rot8, the process is not there anymore.

Is there a way that I can run rot8 with debugging or logging to see what is happening? It seems to me that it crashes for some reason when I run it at startup.

efernau commented 1 year ago

No, rot8 has no debug mode.
actually have neither sway nor a device with accelerometer to reproduce this. but maybe you can use exec_always is it like exec, but the command is executed again, maybe it helps. Or, you are using systemd, maybe you could write a service to start rot8. Otherwise I hope that someone else can help you.

efernau commented 1 year ago

6 looks similar, maybe @deadly-platypus can help

realestninja commented 1 year ago

Man this is a really weird issue haha.

Ok so I have figured out the following: Just making sure I am using the correct display:

$ swaymsg -t get_outputs
Output eDP-1 'SDC 0x415A Unknown' (focused)
  Current mode: 3840x2400 @ 60.000 Hz
  Position: 0,0
  Scale factor: 2.000000
  Scale filter: nearest
  Subpixel hinting: unknown
  Transform: normal
  Workspace: 5: ‭‬ 
  Max render time: off
  Adaptive sync: disabled
  Available modes:
    3840x2400 @ 60.000 Hz

so eDP-1 has to be correct (nothing new on this front).

When I use these lines in my config at startup, it won't work:

exec rot8 --display eDP-1

Now the interesting part: If I run another sway instance within sway, the display name is changed to WL-1 inside that new instance.

So if I set my config to:

exec rot8 --display WL-1

and then launch sway inside of sway, IT WORKS... INSIDE THAT INSTANCE...

swappy-20230209_104307

Info about the screenshot:

I feel like I am getting closer. Something is not quiet right at boot time of the initial sway instance I guess. Maybe eDP-1 is not yet available or something like that. I am not experienced enough to pinpoint it yet, but I will definitely investigate this more. Really enjoy rot8's functionality, so I want it to work at boot 😈

juanbono commented 1 year ago

Did you tried to put a sleep before starting rot8 in your script? Maybe it is a race condition.

realestninja commented 1 year ago

Did you tried to put a sleep before starting rot8 in your script? Maybe it is a race condition.

Yes I have tried that. I got this dummy script that I am executing from in my sway config when sway is launched:

notify-send "sleeping"
sleep 5
notify-send "launching"
rot8

So when sway is launched, I receive the first notification, then the second notification but when I check my process list, rot8 is nowhere to be found.

Is there a way to debug rot8 and write to a log file?

efernau commented 1 year ago

any progress?

realestninja commented 1 year ago

Is it possible to figure out how the rot8 process was ended? With logs, it would be possible to figure out if and why it crashed.

AJK-J commented 2 months ago

I was having this issue. I know I'm a year late on this, but maybe it can help someone else. I installed rot8 with cargo, so I had to append ~/.cargo/bin to $PATH. If you do this after you call exec sway (I did both in my .bashrc) , then the running instance of sway won't have rot8 in it's $PATH

You can test this by writing a simple script that creates a file or leaves some trace, then adding a line in .bashrc that exports the script location to $PATH. Place that export line after exec sway, and reboot. The script will not run. Move the line to after exec sway, and reboot. The script will create the file.

The solution for me was to move exec sway to the bottom of my .bashrc, after I appended rot8 to source. It would probably also work to create a symlink to rot8's location to somewhere that is already in $PATH.