-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathzorg-cli
executable file
·105 lines (82 loc) · 3.18 KB
/
zorg-cli
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#!/usr/bin/python
# -*- coding: utf-8 -*-
#
# Copyright (C) 2005-2010 TUBITAK/UEKAE
#
# This program is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free
# Software Foundation; either version 2 of the License, or (at your option)
# any later version.
#
# Please read the COPYING file.
import sys
import optparse
import comar
import zorg
from zorg.consts import package_sep
from zorg.utils import *
zorg_info = " Xorg AutoConfiguration tool"
link = comar.Link()
def safe():
if link.Xorg.Display["zorg"].safeConfig():
link.Xorg.Display["zorg"].syncConfigs()
print "Initialized a safe configuration using VESA driver."
else:
print "Failed to create a safe configuration with VESA driver."
def probe(opts):
if link.Xorg.Display["zorg"].initialConfig():
link.Xorg.Display["zorg"].syncConfigs()
print "Created an initial configuration for your video device."
else:
print "An error occured while creating an initial configuration."
def setDriver(driver):
# Needed for compatibility with old zorg versions
oldnames = {
"fglrx/ati-drivers": "fglrx",
"nvidia/xorg-video-nvidia96": "nvidia96",
"nvidia/xorg-video-nvidia173": "nvidia173",
"nvidia/xorg-video-nvidia185": "nvidia185",
}
if oldnames.has_key(driver):
driver = oldnames[driver]
if package_sep in driver:
drv, pkg = driver.split(package_sep, 1)
if pkg.replace("-", "_") not in list(link.Xorg.Driver):
print "Package is not installed: %s" % pkg
sys.exit(1)
link.Xorg.Display["zorg"].setDriver(driver)
link.Xorg.Display["zorg"].syncConfigs()
if driver:
print "The video driver is set to '%s'." % driver
else:
print "The video driver will be selected by the X server."
if __name__ == "__main__":
parser = optparse.OptionParser(description = "%s version %s"
% (zorg_info, zorg.versionString()))
parser.add_option("-s", "--safe", action="store_true",
dest="safe", default=False,
help="setup VESA config without probing hardware")
parser.add_option("-p", "--probe", action="store_true",
dest="probe", default=False,
help="force probing all devices, even if xorg.conf exists")
parser.add_option("-d", "--driver", action="store", type="string",
dest="driver", default=None, metavar="DRIVER[%sPACKAGE]" % package_sep,
help="set video card driver to DRIVER")
parser.add_option("-k", "--keymap", action="store", type="string",
dest="keymap", default=None, metavar="LAYOUT[/VARIANT]",
help="changes keyboard map")
opts, args = parser.parse_args()
if opts.safe:
safe()
elif opts.probe:
probe(opts)
elif opts.driver is not None:
setDriver(opts.driver)
elif opts.keymap:
if "/" in opts.keymap:
layout, variant = opts.keymap.split("/", 1)
else:
layout, variant = opts.keymap, ""
link.Xorg.Display["zorg"].setKeymap(layout, variant)
else:
parser.print_help()