Пересобранный и видоизмененный conky для ОСГОС

This commit is contained in:
commit 3a48cf8c86
738 changed files with 217718 additions and 0 deletions

42
extras/CMakeLists.txt Normal file
View file

@ -0,0 +1,42 @@
#
# Conky, a system monitor, based on torsmo
#
# Please see COPYING for details
#
# Copyright (c) 2005-2024 Brenden Matthews, et. al. (see AUTHORS) All rights
# reserved.
#
# 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 3 of the License, or (at your option) any later
# version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
# details. You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/nano)
add_custom_target(conky.nanorc
ALL
COMMAND ${Python3_EXECUTABLE} ${CMAKE_SOURCE_DIR}/doc/render.py nano/conky.nanorc.j2 > ${CMAKE_CURRENT_BINARY_DIR}/nano/conky.nanorc
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
SOURCES
${CMAKE_SOURCE_DIR}/doc/variables.yaml
${CMAKE_SOURCE_DIR}/doc/config_settings.yaml
${CMAKE_SOURCE_DIR}/doc/lua.yaml
${CMAKE_CURRENT_SOURCE_DIR}/nano/conky.nanorc.j2
)
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/vim/syntax)
add_custom_target(conkyrc.vim
ALL
COMMAND ${Python3_EXECUTABLE} ${CMAKE_SOURCE_DIR}/doc/render.py vim/syntax/conkyrc.vim.j2 > ${CMAKE_CURRENT_BINARY_DIR}/vim/syntax/conkyrc.vim
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
SOURCES
${CMAKE_SOURCE_DIR}/doc/variables.yaml
${CMAKE_SOURCE_DIR}/doc/config_settings.yaml
${CMAKE_SOURCE_DIR}/doc/lua.yaml
${CMAKE_CURRENT_SOURCE_DIR}/vim/syntax/conkyrc.vim.j2
)

161
extras/convert.lua Executable file
View file

@ -0,0 +1,161 @@
#! /usr/bin/lua
local usage = [[
Usage: convert.lua old_conkyrc [new_conkyrc]
Tries to convert conkyrc from the old v1.x format to the new, lua-based format.
Keep in mind that there is no guarantee that the output will work correctly
with conky, or that it will be able to convert every conkyrc. However, it
should provide a good starting point.
Although you can use this script with only 1 arg and let it overwrite the old
config, it's suggested to use 2 args so that the new config is written in a new
file (so that you have backup if something went wrong).
Optional: Install dos2unix. We will attempt to use this if it is available
because Conky configs downloaded from Internet sometimes are created on DOS/Windows
machines with different line endings than Conky configs created on Unix/Linux.
For more information about the new format, read the wiki page
<https://github.com/brndnmtthws/conky/wiki>
]];
local function quote(s)
if not s:find("[\n'\\]") then
return "'" .. s .. "'";
end;
local q = '';
while s:find(']' .. q .. ']', 1, true) do
q = q .. '=';
end;
return string.format('[%s[\n%s]%s]', q, s, q);
end;
local bool_setting = {
background = true, disable_auto_reload = true, double_buffer = true, draw_borders = true,
draw_graph_borders = true, draw_outline = true, draw_shades = true, extra_newline = true,
format_human_readable = true, no_buffers = true, out_to_console = true,
out_to_wayland = true,
out_to_ncurses = true, out_to_stderr = true, out_to_x = true, override_utf8_locale = true,
own_window = true, own_window_argb_visual = true, own_window_transparent = true,
short_units = true, show_graph_range = true, show_graph_scale = true,
times_in_seconds = true, top_cpu_separate = true, uppercase = true, use_xft = true,
draw_blended = true, forced_redraw = true
};
local num_setting = {
border_inner_margin = true, border_outer_margin = true, border_width = true,
cpu_avg_samples = true, diskio_avg_samples = true, gap_x = true, gap_y = true,
imlib_cache_flush_interval = true, imlib_cache_size = true,
max_port_monitor_connections = true, max_text_width = true, max_user_text = true,
maximum_width = true, mpd_port = true, music_player_interval = true, net_avg_samples = true,
own_window_argb_value = true, pad_percents = true, stippled_borders = true,
text_buffer_size = true, top_name_width = true, total_run_times = true,
update_interval = true, update_interval_on_battery = true, xftalpha = true,
xinerama_head = true,
};
local split_setting = {
default_bar_size = true, default_gauge_size = true, default_graph_size = true,
minimum_size = true
};
local colour_setting = {
color0 = true, color1 = true, color2 = true, color3 = true, color4 = true, color5 = true,
color6 = true, color7 = true, color8 = true, color9 = true, default_color = true,
default_outline_color = true, default_shade_color = true, own_window_colour = true
};
local function alignment_map(value)
local map = { m = 'middle', t = 'top', b = 'bottom', r = 'right', l = 'left' };
if map[value] == nil then
return value;
else
return map[value];
end;
end;
local function handle(setting, value)
setting = setting:lower();
if setting == '' then
return '';
end;
if split_setting[setting] then
local x, y = value:match('^(%S+)%s*(%S*)$');
local ret = setting:gsub('_size', '_width = ') .. x .. ',';
if y ~= '' then
ret = ret .. ' ' .. setting:gsub('_size', '_height = ') .. y .. ',';
end;
return '\t' .. ret;
end;
if bool_setting[setting] then
value = value:lower();
if value == 'yes' or value == 'true' or value == '1' or value == '' then
value = 'true';
else
value = 'false';
end;
elseif not num_setting[setting] then
if setting == 'alignment' and value:len() == 2 then
value = alignment_map(value:sub(1,1)) .. '_' .. alignment_map(value:sub(2,2));
elseif colour_setting[setting] and value:match('^[0-9a-fA-F]+$') then
value = '#' .. value;
elseif setting == 'xftfont' then
setting = 'font';
end;
value = quote(value);
end;
return '\t' .. setting .. ' = ' .. value .. ',';
end;
local function convert(s)
local setting, comment = s:match('^([^#]*)#?(.*)\n$');
if comment ~= '' then
comment = '--' .. comment;
end;
comment = comment .. '\n';
return handle(setting:match('^%s*(%S*)%s*(.-)%s*$')) .. comment;
end;
local input;
local output;
if conky == nil then --> standalone program
-- 1 arg: arg is input and outputfile
-- 2 args: 1st is inputfile, 2nd is outputfile
-- 0, 3 or more args: print usage to STDERR and quit
if #arg == 1 or #arg == 2 then
if os.execute('command -v dos2unix 2>&1 >/dev/null') == 0 then
os.execute('dos2unix ' .. arg[1]);
end
input = io.input(arg[1]);
else
io.stderr:write(usage);
return;
end;
else
-- we are called from conky, the filename is the first argument
input = io.open(..., 'r');
end;
local config = input:read('*a');
input:close();
local settings, text = config:match('^(.-)TEXT\n(.*)$');
local converted = 'conky.config = {\n' .. settings:gsub('.-\n', convert) .. '};\n\nconky.text = ' ..
quote(text) .. ';\n';
if conky == nil then
if #arg == 2 then
output = io.output(arg[2]);
else
output = io.output(arg[1]);
end
output:write(converted);
output:close();
else
return assert(load(converted, 'converted config'));
end;

326
extras/gedit/conky.lang Normal file
View file

@ -0,0 +1,326 @@
<?xml version="1.0" encoding="UTF-8"?>
<language id="conkyrc" _name="Conky" version="2.0" _section="Others">
<metadata>
<!-- This syntax highlighting will apply for any file with the sequence "conky"
in the file name (or extension), I recommend to use you_config_name.conky
for config files or alternatively conky_your_config_name
Unfortunately this will also trigger the syntax highlighting for this document,
you can always manually set this one back to XML.
If you have a favourite custom format you can change the globs property to your
personal preference. -->
<property name="globs">*conky*</property>
<property name="block-comment-start">--[[</property>
<property name="block-comment-end">]]</property>
</metadata>
<styles>
<style id="config-keyword" _name="Config keywords" map-to="def:keyword"/>
<style id="text-keyword" _name="Text keywords" map-to="def:type"/>
<style id="comment" _name="Comment" map-to="def:comment"/>
<style id="escaped-char" _name="Escaped Character" map-to="def:special-char"/>
<style id="path" _name="Paths and URLs" map-to="def:string"/>
<style id="boolean" _name="Boolean" map-to="def:boolean"/>
<style id="argument" _name="Arguments" map-to="def:preprocessor"/>
<style id="brackets" _name="Text Variable Brackets ${ ... }" map-to="def:identifier"/>
<style id="decimal" _name="Decimal" map-to="def:decimal"/>
</styles>
<definitions>
<!-- ======================================================================================= -->
<!-- Keep in mind gedit does not like < and >, use &lt; and &gt; instead! -->
<!-- Use `ref="id:*"` to include all children of `id` instead of `id` itself -->
<!-- ========================== Container contexts and structure =========================== -->
<!-- "root structure" this is where it all begins -->
<context id="conkyrc" class="no-spell-check">
<include>
<!-- Generic global stuff -->
<!-- Comments -->
<context ref="config-block-comment"/>
<context ref="config-line-comment"/>
<!-- end: Comments -->
<!-- The settings block -->
<context>
<start>(?:(conky)\.(config)(?:\s|\n)*(=)(?:\s|\n)*(\{))</start>
<end>\}</end>
<include>
<!-- Keyword mark highlighter -->
<context sub-pattern="1" where="start" style-ref="config-keyword"/>
<context sub-pattern="2" where="start" style-ref="text-keyword"/>
<!-- end: Keyword mark highlighter -->
<!-- Equals highlighter -->
<context sub-pattern="3" where="start" style-ref="brackets"/>
<!-- end: Equals highlighter -->
<!-- Brackets highlighter -->
<context sub-pattern="4" where="start" style-ref="brackets"/>
<context sub-pattern="0" where="end" style-ref="brackets"/>
<!-- end: Brackets highlighter -->
<!-- Comments -->
<context ref="config-block-comment"/>
<context ref="config-line-comment"/>
<!-- end: Comments -->
<!-- key=val pair -->
<context ref="config-option"/>
<!-- end: key=val -->
</include>
</context>
<!-- end: settings block -->
<!-- The text block -->
<context id="conky-text">
<start>(?:(conky)\.(text)(?:\s|\n)*(=)(?:\s|\n)*)</start>
<end>(?=.|$)</end><!-- End at anything as we only have one child -->
<include>
<!-- Keyword mark highlighter -->
<context sub-pattern="1" where="start" style-ref="config-keyword"/>
<context sub-pattern="2" where="start" style-ref="text-keyword"/>
<!-- end: Keyword mark highlighter -->
<!-- Equals highlighter -->
<context sub-pattern="3" where="start" style-ref="brackets"/>
<!-- end: Equals highlighter -->
<!-- Literal Sub-String -->
<!-- This is just a literal string, really -->
<context ref="lua-lit-string"/>
</include>
</context>
<!-- end: Text block -->
</include>
</context>
<!-- end: root context -->
<!-- ================================== Import groups ================================== -->
<!-- Container for generic includes -->
<!--<context id="generic-container">
<include>
</include>
</context>-->
<!-- end: Generic container -->
<!-- ======================== Component contexts and structure ========================= -->
<!-- Block comment, lua syntax -->
<!-- Note: this will only highlight block comments outside the conky.text section -->
<context id="config-block-comment" style-ref="comment" class="comment" class-disabled="no-spell-check">
<start>--\[(=*)\[</start><end>]\%{1@start}]</end>
<include>
<context ref="def:in-comment"/>
</include>
</context>
<!-- end: Block comment, lua syntax -->
<!-- Line comment, lua syntax -->
<!-- Note: this will only highlight line comments outside the conky.text section -->
<context id="config-line-comment" style-ref="comment" class-disabled="no-spell-check">
<start>\-\-</start><end>$</end>
</context>
<!-- end: Line comment, lua syntax -->
<!-- Line comment, conky text syntax -->
<!-- Note: this will only highlight line comments **inside** the conky.text section -->
<context id="text-comment" style-ref="comment" class-disabled="no-spell-check">
<start>#</start><end>$</end>
</context>
<!-- end: Line comment, conky syntax-->
<!-- String -->
<context id="lua-string" style-ref="argument" style-inside="true"
end-at-line-end="true" class="string">
<start>('|")</start><end>\%{0@start}</end>
<include>
<!-- Quote mark highlighter -->
<context sub-pattern="0" where="start" style-ref="brackets"/>
<context sub-pattern="0" where="end" style-ref="brackets"/>
<!-- end: Quote mark highlighter -->
<!-- Known patterns -->
<!-- Escaped Char (also prevents the context ending prematurely) -->
<context ref="lua-escape"/>
<context ref="path"/>
<context ref="hex-colors"/>
<context ref="predefined-colors"/>
<!-- end: Known patterns -->
</include>
</context>
<!-- end: String value -->
<!-- Literal string -->
<context id="lua-lit-string" once-only="true">
<start>\[\[</start><end>\]\]</end>
<include>
<!-- Quote mark highlighter -->
<context sub-pattern="0" where="start" style-ref="brackets"/>
<context sub-pattern="0" where="end" style-ref="brackets"/>
<!-- end: Quote mark highlighter -->
<!-- Literal Sub-String -->
<!-- We use this to stop premature end of parent -->
<context>
<start>\[\[</start><end>\]\]</end>
<!-- Recursive -->
<include><context ref="lua-lit-string:*"/></include>
</context>
<!-- end: Literal Sub-String -->
<!-- Stuff specific to literal strings (e.g. templates and conky.text) -->
<!-- TODO: Find a clean way to separate template and text lit-strings -->
<context ref="text-escape"/>
<context ref="template-escape"/>
<context ref="text-comment"/>
<context ref="bracket-var"/>
<context ref="text-var"/>
</include>
</context>
<!-- end: Literal string -->
<!-- Escaped char -->
<!-- conky.text escapes -->
<context id="text-escape" style-ref="escaped-char">
<!-- NOTE: Conky doesn't currently escape double backslash -->
<match>\\(?:#|$)</match>
</context>
<!-- template definition escapes -->
<context id="template-escape" style-ref="escaped-char">
<match>\\[n\\ 0-9]</match>
</context>
<!-- lua string escapes -->
<context id="lua-escape" style-ref="escaped-char">
<match>\\[abfnrtv\\"'\[\]]</match>
</context>
<!-- end: Escaped char -->
<!-- File paths and URLs, starting with https://, http://, ~/ or / -->
<context id="path" style-ref="path" class="string">
<match>(?&lt;=\'|\ )(?:\~\/|\/|htt(?:p|ps)\:\/\/){1}[^\s\}\']*</match>
</context>
<!-- end: File paths and URLs -->
<!-- Custom colors (hex) -->
<context id="hex-colors" style-ref="decimal">
<match>(?:[\da-fA-F]{6})</match>
</context>
<!-- end: Custom colors -->
<!-- Predefined colors -->
<!-- Colors parsed by `XParsecolor()` (see /usr/share/X11/rgb.txt (or possibly /usr/lib)) -->
<context id="predefined-colors" style-ref="decimal">
<keyword>red</keyword>
<keyword>green</keyword>
<keyword>yellow</keyword>
<keyword>blue</keyword>
<keyword>magenta</keyword>
<keyword>cyan</keyword>
<keyword>black</keyword>
<keyword>white</keyword>
</context>
<!-- end: Predefined colors -->
<!-- Numbers -->
<context id="number" style-ref="decimal">
<match>(?&lt;=[\ \=]|\dx)([\+\-]{0,1}\d+)([\.\,]{1}\d+)?</match>
</context>
<!-- end: Numbers -->
<!-- Boolean values -->
<context id="boolean" style-ref="boolean">
<keyword>false</keyword>
<keyword>true</keyword>
<keyword>yes</keyword>
<keyword>no</keyword>
</context>
<!-- end: Boolean values -->
<!-- ======================================================================================= -->
<!-- key=val pair -->
<context id="config-option">
<start>[A-Za-z0-9_]+</start>
<!-- ended by value -->
<include>
<!-- Keyword highlight -->
<context sub-pattern="0" where="start" style-ref="config-keyword"/>
<!-- end: Keyword highlight -->
<!-- value -->
<context end-parent="true">
<start>=</start><end>(?:,|(?=\}))</end>
<include>
<!-- Equals highlight -->
<context sub-pattern="0" where="start" style-ref="brackets"/>
<!-- end: Equals highlight -->
<!-- Value types -->
<context ref="lua-string"/>
<context ref="lua-lit-string"/>
<context ref="number"/>
<context ref="boolean"/>
<!-- end: Value types -->
<!-- Comments -->
<context ref="config-block-comment"/>
<context ref="config-line-comment"/>
<!-- end: Comments -->
</include>
</context>
<!-- end: value -->
<!-- Comments -->
<context ref="config-block-comment"/>
<context ref="config-line-comment"/>
<!-- end: Comments -->
</include>
</context>
<!-- end: key=val -->
<!-- TextVariables -->
<!-- Bracket style -->
<context id="bracket-var" style-ref="argument" style-inside="true">
<start>(?:(\$\{)(?:\s|\n|$)*([a-z][a-z0-9_]*))</start>
<end>\}</end>
<include>
<!-- Brackets highlighter -->
<context sub-pattern="1" where="start" style-ref="brackets"/>
<context sub-pattern="0" where="end" style-ref="brackets"/>
<!-- end: Brackets highlighter -->
<!-- Variable/keyword highlighter -->
<context sub-pattern="2" where="start" style-ref="text-keyword"/>
<!-- Special patterns -->
<context ref="number"/>
<context ref="boolean"/>
<context ref="path"/>
<context ref="hex-colors"/>
<context ref="predefined-colors"/>
<!-- end: Special patterns -->
<!-- Inherit from lit-String -->
<context ref="lua-lit-string:*"/>
</include>
</context>
<!-- non-bracket style -->
<context id="text-var" style-ref="text-keyword" style-inside="true">
<start>(?:(\$)(?!\{))</start>
<end>(?:(?=[^A-Za-z0-9_])|$)</end>
<include>
<!-- Dollar highlighter -->
<context sub-pattern="1" where="start" style-ref="brackets"/>
<!-- end: Dollar highlighter -->
</include>
</context>
<!-- end: TextVariables -->
</definitions>
</language>

View file

@ -0,0 +1,18 @@
##
## Syntax highlighting for conkyrc files.
##
##
syntax "conky" "(\.*conkyrc.*$|conky.conf)"
## Configuration items
color green "\<({{ config_settings['values']|map(attribute="name")|join('|') }})\>"
## Configuration item constants
color yellow "\<(above|below|bottom_left|bottom_right|bottom_middle|desktop|dock|no|none|normal|override|skip_pager|skip_taskbar|sticky|top_left|top_right|top_middle|middle_left|middle_right|middle_middle|undecorated|yes)\>"
## Variables
color brightblue "\<({{ variables['values']|map(attribute="name")|join('|') }})\>"
color brightblue "\$\{?[0-9A-Z_!@#$*?-]+\}?"
color cyan "(\{|\}|\(|\)|\;|\]|\[|`|\\|\$|<|>|!|=|&|\|)"
color brightred "^TEXT$"

View file

@ -0,0 +1,3 @@
" Vim filetype detection file for Conky config files
au BufNewFile,BufRead *conkyrc,conky.conf set filetype=conkyrc

View file

@ -0,0 +1,65 @@
" Vim syntax file
" Language: conkyrc
" Author: Ciaran McCreesh <ciaranm@gentoo.org>
" Version: 20060307
" Copyright: Copyright (c) 2005 Ciaran McCreesh
" Licence: You may redistribute this under the same terms as Vim itself
"
if exists("b:current_syntax")
finish
endif
syn region ConkyrcComment start=/^\s*#/ end=/$/
syn keyword ConkyrcSetting {{ config_settings['values']|map(attribute="name")|join(' ') }}
syn keyword ConkyrcConstant
\ above
\ below
\ bottom_left
\ bottom_right
\ bottom_middle
\ desktop
\ dock
\ no
\ none
\ normal
\ override
\ skip_pager
\ skip_taskbar
\ sticky
\ top_left
\ top_right
\ top_middle
\ middle_left
\ middle_right
\ middle_middle
\ undecorated
\ yes
syn match ConkyrcNumber /\S\@<!\d\+\(\.\d\+\)\?\(\S\@!\|}\@=\)/
\ nextgroup=ConkyrcNumber,ConkyrcColour skipwhite
syn match ConkyrcColour /\S\@<!#[a-fA-F0-9]\{6\}\(\S\@!\|}\@=\)/
\ nextgroup=ConkyrcNumber,ConkyrcColour skipwhite
syn region ConkyrcText start=/^TEXT$/ end=/\%$/ contains=ConkyrcVar
syn region ConkyrcVar start=/\${/ end=/}/ contained contains=ConkyrcVarStuff
syn region ConkyrcVar start=/\$\w\@=/ end=/\W\@=\|$/ contained contains=ConkyrcVarName
syn match ConkyrcVarStuff /{\@<=/ms=s contained nextgroup=ConkyrcVarName
syn keyword ConkyrcVarName contained nextgroup=ConkyrcNumber,ConkyrcColour skipwhite {{ variables['values']|map(attribute="name")|join(' ') }}
hi def link ConkyrcComment Comment
hi def link ConkyrcSetting Keyword
hi def link ConkyrcConstant Constant
hi def link ConkyrcNumber Number
hi def link ConkyrcColour Special
hi def link ConkyrcText String
hi def link ConkyrcVar Identifier
hi def link ConkyrcVarName Keyword
let b:current_syntax = "conkyrc"