tps.rotate

tps.rotate.can_use_chvt()

Checks whether chvt can be called with sudo without a password.

The sudo command has the -n option which will just make the command fail when the user does not have the appropriate permissions. The problem with chvt is that it does not have any intelligent command line argument parsing. If will return code 1 if no argument is given, the same code that sudo gives when no permission is available. Therefore I chose to use sudo -l` to get the whole list and see whether the full path to ``chvt is in there. This might break on Fedora where the usr-merge has been done now.

The following line is needed in a file like /etc/sudoers.d/chvt:

myuser  ALL = NOPASSWD: /bin/chvt

You have to replace myuser which your username. Giving too broad permissions to every other user account is probably not a good idea.

Return type:bool
tps.rotate.has_external_screens(config)

Checks whether any external screens are attached.

tps.rotate.main()

Entry point for thinkpad-rotate.

tps.rotate.needs_xrandr_bug_workaround(config)

Determines whether xrandr bug needs to be worked around.

XRandr has a bug in Ubuntu, maybe even in other distributions. In Ubuntu 15.04 a workaround is to change the virtual terminal to a different one and back to the seventh, the graphical one. This can be automated using the chvt command which requires superuser privileges. An entry in the sudo file can let the normal user execute this program.

tps.rotate.new_rotation(current, desired_str, config, force=False)

Determines the new rotation based on desired and current one.

Parameters:force (bool) – If set the function does not try to be too clever but

just uses the rotation given. If no rotation is given in desired_str, it still uses the default from the configuration.

tps.rotate.rotate_to(direction, config)

Performs all steps needed for a screen rotation.

tps.rotate.toggle_virtual_terminal()
tps.rotate.xrandr_bug_fail_early(config)

Quits the program if xrandr bug cannot be coped with.