mirror of
https://github.com/libratbag/libratbag.git
synced 2026-11-07 15:14:38 +01:00
tools: ratbagctl: add support for resolution default set/get
https://github.com/libratbag/libratbag/issues/246 Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
committed by
Benjamin Tissoires
parent
bf18e9b795
commit
9fe892f10f
@@ -338,6 +338,23 @@ def func_resolution_active_get(r, args):
|
||||
print(r.index)
|
||||
|
||||
|
||||
def func_resolution_default_get(r, args):
|
||||
p, d = find_profile(r, args)
|
||||
for r in p.resolutions:
|
||||
if r.is_default:
|
||||
break
|
||||
else:
|
||||
r = None
|
||||
print(r.index)
|
||||
|
||||
|
||||
def func_default_resolution_set(r, args):
|
||||
# FIXME: capabilities check?
|
||||
r, p, d = find_resolution(r, args)
|
||||
r.set_default()
|
||||
d.commit()
|
||||
|
||||
|
||||
def func_profile_get(r, args):
|
||||
p, d = find_profile(r, args)
|
||||
print_profile(d, p, 0)
|
||||
@@ -602,6 +619,34 @@ parser_def = [
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
of_type: switch,
|
||||
name: 'default',
|
||||
help_str: 'access default resolution information',
|
||||
switch: [
|
||||
{
|
||||
of_type: command,
|
||||
name: 'get',
|
||||
help_str: 'Show current default resolution',
|
||||
func: func_resolution_default_get,
|
||||
},
|
||||
{
|
||||
of_type: command,
|
||||
name: 'set',
|
||||
help_str: 'Set current default resolution',
|
||||
pos_args: [
|
||||
{
|
||||
of_type: argument,
|
||||
name: 'resolution_n',
|
||||
metavar: 'N',
|
||||
help_str: 'The resolution to set as default',
|
||||
arg_type: int,
|
||||
},
|
||||
],
|
||||
func: func_default_resolution_set,
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
N_access: {
|
||||
of_type: N_access,
|
||||
|
||||
@@ -235,6 +235,25 @@ class TestRatbgagCtlResolution(TestRatbagCtl):
|
||||
r = self.launch_good_test("Profile 2 Resolution 2 get test_device")
|
||||
self.assertEqual(r, "2: 2300x2400dpi @ 3000Hz")
|
||||
|
||||
def test_resolution_default_get(self):
|
||||
command = "Resolution default get"
|
||||
r = self.launch_good_test(command + " test_device")
|
||||
self.assertEqual(int(r), 1)
|
||||
self.launch_fail_test(command + " X test_device")
|
||||
self.launch_fail_test(command + " 10 test_device")
|
||||
self.launch_fail_test(command + " test_device x")
|
||||
|
||||
def test_resolution_default_set(self):
|
||||
command = "Resolution default set"
|
||||
self.launch_good_test(command + " 2 test_device")
|
||||
r = self.launch_good_test("Resolution default get test_device")
|
||||
self.assertEqual(int(r), 2)
|
||||
self.launch_fail_test(command)
|
||||
self.launch_fail_test(command + " X test_device")
|
||||
self.launch_fail_test(command + " 1 test_device X")
|
||||
# Reset for other tests
|
||||
self.launch_good_test(command + " 1 test_device")
|
||||
|
||||
|
||||
class TestRatbgagCtlDPI(TestRatbagCtl):
|
||||
@classmethod
|
||||
|
||||
Reference in New Issue
Block a user