mirror of
https://github.com/vale981/clay
synced 2025-03-04 17:11:41 -05:00
Configure x keybinds through the configuration file and load colours from a seperate file
This commit is contained in:
parent
75f372aba3
commit
60d910e930
4 changed files with 123 additions and 125 deletions
24
clay/app.py
24
clay/app.py
|
@ -183,7 +183,7 @@ class AppWidget(urwid.Frame):
|
|||
return
|
||||
|
||||
with settings.edit() as config:
|
||||
config['authtoken'] = gp.get_authtoken()
|
||||
config['play_settings']['authtoken'] = gp.get_authtoken()
|
||||
|
||||
self._login_notification.close()
|
||||
|
||||
|
@ -346,26 +346,34 @@ def main():
|
|||
|
||||
parser.add_argument("-v", "--version", action=MultilineVersionAction)
|
||||
|
||||
parser.add_argument(
|
||||
keybinds_group = parser.add_mutually_exclusive_group()
|
||||
|
||||
keybinds_group.add_argument(
|
||||
"--with-x-keybinds",
|
||||
help="define global X keybinds (requires Keybinder and PyGObject)",
|
||||
action='store_true'
|
||||
)
|
||||
|
||||
keybinds_group.add_argument(
|
||||
"--without-x-keybinds",
|
||||
help="Don't define global keybinds (overrides configuration file)",
|
||||
action='store_true'
|
||||
)
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
if args.version:
|
||||
exit(0)
|
||||
|
||||
if args.with_x_keybinds:
|
||||
if (args.with_x_keybinds or settings.get('x_keybinds', 'clay_settings')) \
|
||||
and not args.without_x_keybinds:
|
||||
player.enable_xorg_bindings()
|
||||
|
||||
# Run the actual program
|
||||
palette = []
|
||||
for name in settings.get_default_config_section("colours"):
|
||||
res = settings.get(name, "colours")
|
||||
palette.append((name, '', '', '', res['foreground'], res['background']))
|
||||
# Create a 256 colour palette.
|
||||
palette = [(name, '', '', '', res['foreground'], res['background'])
|
||||
for name, res in settings.colours_config.items()]
|
||||
|
||||
# Run the actual program
|
||||
app_widget = AppWidget()
|
||||
loop = urwid.MainLoop(app_widget, palette)
|
||||
app_widget.set_loop(loop)
|
||||
|
|
95
clay/colours.yaml
Normal file
95
clay/colours.yaml
Normal file
|
@ -0,0 +1,95 @@
|
|||
default: &default
|
||||
foreground: "#FFF"
|
||||
background: "#222"
|
||||
|
||||
primary: &primary
|
||||
foreground: "#F54"
|
||||
background: "#FFF"
|
||||
|
||||
primary_inv: &primary_inv
|
||||
foreground: "#FFF"
|
||||
background: "#F54"
|
||||
|
||||
secondary: &secondary
|
||||
foreground: "#17F"
|
||||
background: "#FFF"
|
||||
|
||||
secondary_inv: &secondary_inv
|
||||
foreground: "#FFF"
|
||||
background: "#17F"
|
||||
|
||||
background: *default
|
||||
None: *default
|
||||
'': *default
|
||||
|
||||
logo: *primary
|
||||
progress: *primary
|
||||
progressbar_done: *primary
|
||||
selected: *primary_inv
|
||||
|
||||
progress_remaining:
|
||||
foreground: "#FFF"
|
||||
background: "#444"
|
||||
|
||||
progressbar_done_paused:
|
||||
<<: *default
|
||||
foreground: null
|
||||
|
||||
progressbar_remaining:
|
||||
<<: *default
|
||||
foreground: "#222"
|
||||
|
||||
title-idle:
|
||||
<<: *default
|
||||
foreground: null
|
||||
|
||||
title-playing: *primary
|
||||
|
||||
panel:
|
||||
foreground: "#FFF"
|
||||
background: "#222"
|
||||
|
||||
panel_focus: *primary_inv
|
||||
|
||||
panel_divider:
|
||||
foreground: "#444"
|
||||
background: "#222"
|
||||
|
||||
panel_divider_focus:
|
||||
foreground: "#444"
|
||||
background: '#F54'
|
||||
|
||||
line1: *default
|
||||
line1_focus:
|
||||
foreground: "#FFF"
|
||||
background: "#333"
|
||||
|
||||
line1_active: *primary
|
||||
|
||||
line1_active_focus:
|
||||
foreground: "#F54"
|
||||
background: "#333"
|
||||
|
||||
line2:
|
||||
<<: *default
|
||||
foreground: "#AAA"
|
||||
|
||||
line2_focus:
|
||||
foreground: "#AAA"
|
||||
background: "#333"
|
||||
|
||||
input:
|
||||
foreground: "#FFF"
|
||||
background: "#444"
|
||||
|
||||
input_focus: *primary_inv
|
||||
|
||||
flag:
|
||||
<<: *default
|
||||
foreground: "#AAA"
|
||||
|
||||
flag-active: *primary
|
||||
|
||||
notification:
|
||||
foreground: "#F54"
|
||||
background: "#222"
|
120
clay/config.yaml
120
clay/config.yaml
|
@ -1,126 +1,12 @@
|
|||
#: pylint:skip-file
|
||||
hotkeys:
|
||||
|
||||
clay_settings:
|
||||
x_keybinds: false
|
||||
|
||||
play_settings:
|
||||
authtoken: ""
|
||||
device_id: ""
|
||||
download_tracks: false
|
||||
password: ""
|
||||
username: ""
|
||||
|
||||
colours:
|
||||
default: &def
|
||||
foreground: "#FFF"
|
||||
background: "#222"
|
||||
|
||||
background: *def
|
||||
None: *def
|
||||
|
||||
logo:
|
||||
<<: *def
|
||||
foreground: "#F54"
|
||||
|
||||
primary:
|
||||
foreground: "#F54"
|
||||
background: "#FFF"
|
||||
|
||||
secondary:
|
||||
foreground: "#17F"
|
||||
background: "#FFF"
|
||||
|
||||
selected:
|
||||
foreground: "#FFF"
|
||||
background: "#444"
|
||||
|
||||
primary_inv:
|
||||
foreground: "#FFF"
|
||||
background: "#17F"
|
||||
|
||||
secondary_inv:
|
||||
foreground: "#FFF"
|
||||
background: "#F17"
|
||||
|
||||
progress:
|
||||
foreground: "#FFF"
|
||||
background: "#F54"
|
||||
|
||||
progress_remaining:
|
||||
foreground: "#FFF"
|
||||
background: "#444"
|
||||
|
||||
progressbar_done:
|
||||
<<: *def
|
||||
foreground: "#F54"
|
||||
|
||||
progressbar_done_paused:
|
||||
<<: *def
|
||||
foreground: null
|
||||
|
||||
progressbar_remaining:
|
||||
<<: *def
|
||||
foreground: "#222"
|
||||
|
||||
title-idle:
|
||||
<<: *def
|
||||
foreground: null
|
||||
|
||||
title-playing:
|
||||
<<: *def
|
||||
foreground: "#F54"
|
||||
|
||||
panel:
|
||||
foreground: "#FFF"
|
||||
background: "#222"
|
||||
|
||||
panel_focus:
|
||||
foreground: "#FFF"
|
||||
background: "#F54"
|
||||
|
||||
panel_divider:
|
||||
foreground: "#444"
|
||||
background: "#222"
|
||||
|
||||
panel_divider_focus:
|
||||
foreground: "#444"
|
||||
background: '#F54'
|
||||
|
||||
line1: *def
|
||||
line1_focus:
|
||||
foreground: "#FFF"
|
||||
background: "#333"
|
||||
|
||||
line1_active:
|
||||
<<: *def
|
||||
foreground: "#F54"
|
||||
|
||||
line1_active_focus:
|
||||
foreground: "#F54"
|
||||
background: "#333"
|
||||
|
||||
line2:
|
||||
<<: *def
|
||||
foreground: "#AAA"
|
||||
|
||||
line2_focus:
|
||||
foreground: "#AAA"
|
||||
background: "#333"
|
||||
|
||||
input:
|
||||
foreground: "#FFF"
|
||||
background: "#444"
|
||||
|
||||
input_focus:
|
||||
foreground: "#FFF"
|
||||
background: "#F54"
|
||||
|
||||
flag:
|
||||
<<: *def
|
||||
foreground: "#AAA"
|
||||
|
||||
flag-active:
|
||||
foreground: "#F54"
|
||||
<<: *def
|
||||
|
||||
notification:
|
||||
foreground: "#F54"
|
||||
background: "#222"
|
||||
|
|
|
@ -59,6 +59,7 @@ class _Settings(object):
|
|||
"""
|
||||
self._config_dir = appdirs.user_config_dir('clay', 'Clay')
|
||||
self._config_file_path = os.path.join(self._config_dir, 'config.yaml')
|
||||
self._colours_file_path = os.path.join(self._config_dir, 'colours.yaml')
|
||||
|
||||
try:
|
||||
os.makedirs(self._config_dir)
|
||||
|
@ -87,6 +88,14 @@ class _Settings(object):
|
|||
# Load the configuration from Setuptools' ResourceManager API
|
||||
self._default_config = yaml.load(pkg_resources.resource_string(__name__, "config.yaml"))
|
||||
|
||||
# We only either the user colour or the default colours to ease parsing logic.
|
||||
if os.path.exists(self._colours_file_path):
|
||||
with open(self._colours_file_path, 'r') as colours_file:
|
||||
self.colours_config = yaml.load(colours_file.read())
|
||||
else:
|
||||
self.colours_config = yaml.load(pkg_resources.resource_string(__name__, "colours.yaml"))
|
||||
|
||||
|
||||
def _load_cache(self):
|
||||
"""
|
||||
Load cached files.
|
||||
|
|
Loading…
Add table
Reference in a new issue