-
Notifications
You must be signed in to change notification settings - Fork 51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add cycler method for cycling change the resolution and transform (New) #1576
Conversation
replace the old gnome_randr_cycle.py.
2. try to fix TypeError
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1576 +/- ##
=======================================
Coverage 48.00% 48.00%
=======================================
Files 371 370 -1
Lines 39833 39832 -1
Branches 6730 6728 -2
=======================================
Hits 19121 19121
Misses 19994 19994
+ Partials 718 717 -1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for working on this! A few suggestions below, mostly for clearness.
Do you have a test job we can use for testing?
Co-authored-by: Paolo Gentili <paolo.gentili@canonical.com>
The example code is #!/usr/bin/env python3
from collections import namedtuple
from typing import List
from fractions import Fraction
from checkbox_support.monitor_config import MonitorConfig
from checkbox_support.helpers import display_info
import subprocess
import time
Mode = namedtuple("Mode", ["id", "resolution", "is_preferred", "is_current"])
def resolution_filter(modes: List[Mode]):
new_modes = []
tmp_resolution = []
sort_modes = sorted(
modes, key=lambda m: int(m.resolution.split("x")[0]), reverse=True
)
for m in sort_modes:
width, height = [int(x) for x in m.resolution.split("x")]
aspect = Fraction(width, height)
if width < 675 or width / aspect < 530:
continue
if m.resolution in tmp_resolution:
continue
if len(new_modes) >= 5:
break
new_modes.append(m)
tmp_resolution.append(m.resolution)
return new_modes
def action(filename, **kwargs):
print(filename)
time.sleep(5)
subprocess.check_output(["sudo", "keyboard_mouse"])
subprocess.check_output(["gnome-screenshot", "-f", filename])
def cycle_test():
try:
monitor_config = display_info.get_monitor_config()
except ValueError as exc:
raise SystemExit("Current host is not support")
monitor_config.cycle(res=False, resolution_filter=None, transform=True, action=action)
if __name__ == "__main__":
cycle_test() the source code of keyboard_mouse command is in #1582 |
2. zip monitors and mode to make loop easier
logic as they want.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks for all the changes!
Description
According to the #855 , parsing the output from gnome_randr is not acceptable. Therefore, add cycler method for cycling change the resolution and transform to instead of modifying the old gnome_randr_cycle.py.
Resolved issues
The private bug
Documentation
Tests