mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-28 03:01:57 +02:00
add special value listjson in panel output-name
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# License: GPL v3 Copyright: 2016, Kovid Goyal <kovid at kovidgoyal.net>
|
# License: GPL v3 Copyright: 2016, Kovid Goyal <kovid at kovidgoyal.net>
|
||||||
|
|
||||||
|
import json
|
||||||
import locale
|
import locale
|
||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
@@ -222,13 +223,24 @@ def is_panel_kitten() -> bool:
|
|||||||
return _is_panel_kitten
|
return _is_panel_kitten
|
||||||
|
|
||||||
|
|
||||||
def list_monitors() -> None:
|
def list_monitors(json_output: bool = False) -> None:
|
||||||
monitor_names = glfw_get_monitor_names()
|
monitor_names = glfw_get_monitor_names()
|
||||||
has_descriptions = False
|
has_descriptions = False
|
||||||
for (name, desc) in monitor_names:
|
for (name, desc) in monitor_names:
|
||||||
if desc:
|
if desc:
|
||||||
has_descriptions = True
|
has_descriptions = True
|
||||||
break
|
break
|
||||||
|
|
||||||
|
if json_output:
|
||||||
|
if has_descriptions:
|
||||||
|
monitors_list_of_dict = [{'name': name, 'desc': desc} for name, desc in monitor_names]
|
||||||
|
else:
|
||||||
|
monitors_list_of_dict = [{'name': name} for name, _ in monitor_names]
|
||||||
|
|
||||||
|
json.dump(monitors_list_of_dict, sys.stdout)
|
||||||
|
print()
|
||||||
|
return
|
||||||
|
|
||||||
isatty = sys.stdout.isatty()
|
isatty = sys.stdout.isatty()
|
||||||
for (name, desc) in monitor_names:
|
for (name, desc) in monitor_names:
|
||||||
if isatty:
|
if isatty:
|
||||||
@@ -243,8 +255,9 @@ def list_monitors() -> None:
|
|||||||
def _run_app(opts: Options, args: CLIOptions, bad_lines: Sequence[BadLine] = (), talk_fd: int = -1) -> None:
|
def _run_app(opts: Options, args: CLIOptions, bad_lines: Sequence[BadLine] = (), talk_fd: int = -1) -> None:
|
||||||
global _is_panel_kitten
|
global _is_panel_kitten
|
||||||
_is_panel_kitten = run_app.cached_values_name == 'panel'
|
_is_panel_kitten = run_app.cached_values_name == 'panel'
|
||||||
if _is_panel_kitten and run_app.layer_shell_config and run_app.layer_shell_config.output_name == 'list':
|
if _is_panel_kitten and run_app.layer_shell_config and run_app.layer_shell_config.output_name in ['list', 'listjson']:
|
||||||
list_monitors()
|
is_json_output = run_app.layer_shell_config.output_name == 'listjson'
|
||||||
|
list_monitors(is_json_output)
|
||||||
return
|
return
|
||||||
if is_macos:
|
if is_macos:
|
||||||
global_shortcuts = set_cocoa_global_shortcuts(opts)
|
global_shortcuts = set_cocoa_global_shortcuts(opts)
|
||||||
|
|||||||
@@ -660,7 +660,8 @@ Syntax: :italic:`name=value`. For example: :option:`kitty +kitten panel -o` font
|
|||||||
The panel can only be displayed on a single monitor (output) at a time. This allows
|
The panel can only be displayed on a single monitor (output) at a time. This allows
|
||||||
you to specify which output is used, by name. If not specified the compositor will choose an
|
you to specify which output is used, by name. If not specified the compositor will choose an
|
||||||
output automatically, typically the last output the user interacted with or the primary monitor.
|
output automatically, typically the last output the user interacted with or the primary monitor.
|
||||||
Use the special value :code:`list` to get a list of available outputs.
|
Use the special value :code:`list` to get a list of available outputs. Use :code:`listjson` for
|
||||||
|
a json encoded output.
|
||||||
|
|
||||||
|
|
||||||
--class --app-id
|
--class --app-id
|
||||||
|
|||||||
Reference in New Issue
Block a user