Skip to content

Commit 87cae15

Browse files
authored
Build plank themes using meson (#78)
- Get accent colors from cinnamon - Add option to colorize-dummy-svg to output color in rgb
1 parent ba4c351 commit 87cae15

8 files changed

+150
-2
lines changed

cinnamon-shell/src/meson.build

+2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ variants = [
1010

1111
DEFAULT_VARIANT = 'light'
1212
message(meson.project_build_root())
13+
sucharu_colors_defs = {}
1314

1415
foreach accent: enabled_accent_colors
1516
if enabled_accent_colors.contains(accent)
@@ -121,6 +122,7 @@ foreach variant: variants
121122
theme_sources,
122123
]
123124
)
125+
sucharu_colors_defs += {theme_full_name: shell_sucharu_colors_defs}
124126

125127
# generate .css files
126128
variant_styles = []

common/colorize-dummy-svg.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747

4848
assert len(set(DUMMY_COLORS.values())) == len(DUMMY_COLORS.values())
4949

50-
def read_colors_replacements(css_file):
50+
def read_colors_replacements(css_file, hex2rgb):
5151
colors_replacements = {}
5252

5353
for l in css_file.readlines():
@@ -56,6 +56,9 @@ def read_colors_replacements(css_file):
5656
continue
5757

5858
[named_color, color] = line.split('-sucharu-', 1)[-1].split(': ')
59+
if hex2rgb:
60+
hexa = color.lstrip('#')
61+
color = ';;'.join(str(int(hexa[i:i+2], 16)) for i in (0, 2, 4))
5962
colors_replacements[DUMMY_COLORS[named_color]] = color
6063
print(named_color, color, f'(replaces {DUMMY_COLORS[named_color]})')
6164

@@ -86,9 +89,10 @@ def replace_colors(svg, replacements, output_folder, variant):
8689
parser.add_argument('--variant', default=None)
8790
parser.add_argument('--filter', action='append', default=[])
8891
parser.add_argument('--exclude', action='append', default=[])
92+
parser.add_argument('--hex2rgb', default=False)
8993

9094
args = parser.parse_args()
91-
replacements = read_colors_replacements(args.sucharu_colors_defs_scss)
95+
replacements = read_colors_replacements(args.sucharu_colors_defs_scss, args.hex2rgb)
9296
variant = None if args.variant == 'default' else args.variant
9397

9498
if args.input_file:

meson.build

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ components = [
2323
'ubuntu-unity',
2424
'xfwm4',
2525
'cinnamon-shell',
26+
'plank',
2627
]
2728

2829
enabled_accent_colors = get_option('accent-colors')

meson_options.txt

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ option('dark', type: 'boolean', value: true, description:'build Sucharu dark fla
1616
option('darker', type: 'boolean', value: true, description:'build Sucharu darker flavour')
1717
option('ubuntu-unity', type: 'boolean', value: false, description:'build Sucharu with Unity assets')
1818
option('xfwm4', type: 'boolean', value: false, description:'build Sucharu with xfwm4 assets')
19+
option('plank', type: 'boolean', value: true, description:'build Sucharu with plank assets')
1920
# option('cinnamon', type: 'boolean', value: false, description:'build Sucharu with Cinnamon flavour')
2021
# option('cinnamon-dark', type: 'boolean', value: false, description:'build Sucharu with Cinnamon dark flavour')
2122

plank/meson.build

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
plank_default_theme_dir = join_paths(get_option('datadir'), 'plank/themes')
2+
3+
flavours = []
4+
foreach flavour: ['default', 'dark']
5+
if not get_option(flavour)
6+
message('skip flavour ' + flavour)
7+
continue
8+
endif
9+
flavours += flavour
10+
endforeach
11+
12+
subdir('src')

plank/src/dock.theme.in

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
[PlankTheme]
2+
#The roundness of the top corners.
3+
TopRoundness=50
4+
#The roundness of the bottom corners.
5+
BottomRoundness=0
6+
#The thickness (in pixels) of lines drawn.
7+
LineWidth=2
8+
#The color (RGBA) of the outer stroke.
9+
OuterStrokeColor=#ff0001;;255
10+
#The starting color (RGBA) of the fill gradient.
11+
FillStartColor=#00ff01;;192
12+
#The ending color (RGBA) of the fill gradient.
13+
FillEndColor=#00ff01;;192
14+
#The color (RGBA) of the inner stroke.
15+
InnerStrokeColor=#ff0001;;255
16+
17+
[PlankDockTheme]
18+
#The padding on the left/right dock edges, in tenths of a percent of IconSize.
19+
HorizPadding=1
20+
#The padding on the top dock edge, in tenths of a percent of IconSize.
21+
TopPadding=-6
22+
#The padding on the bottom dock edge, in tenths of a percent of IconSize.
23+
BottomPadding=1.5
24+
#The padding between items on the dock, in tenths of a percent of IconSize.
25+
ItemPadding=2
26+
#The size of item indicators, in tenths of a percent of IconSize.
27+
IndicatorSize=5
28+
#The size of the icon-shadow behind every item, in tenths of a percent of IconSize.
29+
IconShadowSize=1.2
30+
#The height (in percent of IconSize) to bounce an icon when the application sets urgent.
31+
UrgentBounceHeight=1.6666666666666667
32+
#The height (in percent of IconSize) to bounce an icon when launching an application.
33+
LaunchBounceHeight=0.625
34+
#The opacity value (0 to 1) to fade the dock to when hiding it.
35+
FadeOpacity=1
36+
#The amount of time (in ms) for click animations.
37+
ClickTime=300
38+
#The amount of time (in ms) to bounce an urgent icon.
39+
UrgentBounceTime=0
40+
#The amount of time (in ms) to bounce an icon when launching an application.
41+
LaunchBounceTime=600
42+
#The amount of time (in ms) for active window indicator animations.
43+
ActiveTime=300
44+
#The amount of time (in ms) to slide icons into/out of the dock.
45+
SlideTime=300
46+
#The time (in ms) to fade the dock in/out on a hide (if FadeOpacity is < 1).
47+
FadeTime=250
48+
#The time (in ms) to slide the dock in/out on a hide (if FadeOpacity is 1).
49+
HideTime=200
50+
#The size of the urgent glow (shown when dock is hidden), in tenths of a percent of IconSize.
51+
GlowSize=0
52+
#The total time (in ms) to show the hidden-dock urgent glow.
53+
GlowTime=0
54+
#The time (in ms) of each pulse of the hidden-dock urgent glow.
55+
GlowPulseTime=0
56+
#The hue-shift (-180 to 180) of the urgent indicator color.
57+
UrgentHueShift=150
58+
#The time (in ms) to move an item to its new position or its addition/removal to/from the dock.
59+
ItemMoveTime=200
60+
#Whether background and icons will unhide/hide with different speeds. The top-border of both will leave/hit the screen-edge at the same time.
61+
CascadeHide=true
62+
#The color (RGBA) of the badge displaying urgent count
63+
BadgeColor=0;;0;;0;;0

plank/src/meson.build

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
plank_theme_dir = plank_default_theme_dir
2+
3+
variants = [
4+
'default',
5+
'dark',
6+
]
7+
8+
foreach accent: enabled_accent_colors
9+
if enabled_accent_colors.contains(accent)
10+
variants += (get_option('default') ? [accent] : [])
11+
variants += (get_option('dark') ? [ accent + '-dark' ] : [])
12+
endif
13+
endforeach
14+
15+
foreach variant: variants
16+
if not get_option('cinnamon-shell')
17+
warning('cinnamon-shell is not enabled, so we won\'t be able to generate plank themes.')
18+
continue
19+
endif
20+
21+
is_dark = variant == 'dark' or variant.endswith('-dark')
22+
is_variant = variant != 'default'
23+
variant_base_name = is_dark ? variant.split('-dark')[0] : variant
24+
variant_suffix = is_variant ? '-@0@'.format(variant) : ''
25+
theme_full_name = meson.project_name() + variant_suffix
26+
is_custom_accent = enabled_accent_colors.contains(variant_base_name)
27+
message(theme_full_name)
28+
29+
install_dir = join_paths(plank_theme_dir, theme_full_name)
30+
target_name = theme_full_name + '-' + 'dock.theme'
31+
message(target_name)
32+
33+
colors_definitions = sucharu_colors_defs['@0@'.format(theme_full_name)]
34+
accented_theme = custom_target(
35+
'___'.join('@0@'.format(target_name).split('/')),
36+
input: 'dock.theme.in',
37+
output: target_name,
38+
command: [
39+
colorize_dummy_svg,
40+
colors_definitions,
41+
'--input-file', '@INPUT@',
42+
'--output-folder', '@OUTDIR@',
43+
'--variant', variant,
44+
'--hex2rgb', 'True',
45+
],
46+
depends: colors_definitions,
47+
build_by_default: true,
48+
)
49+
# rename theme variant
50+
replacestring = theme_full_name.replace(meson.project_name(), '') + '.svg'
51+
curr_theme = join_paths(meson.current_build_dir(), ('dock.theme' + replacestring))
52+
# install_data(curr_theme,
53+
# rename: 'dock.theme',
54+
# install_dir: install_dir)
55+
56+
meson.add_install_script('rename-plank-theme.sh', curr_theme, install_dir)
57+
endforeach

plank/src/rename-plank-theme.sh

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/usr/bin/env bash
2+
# -*- coding: UTF-8 -*-
3+
4+
# rename and install plank themes
5+
6+
7+
mkdir -p "${DESTDIR}${MESON_INSTALL_PREFIX}/$2"
8+
cp -uv "$1" "${DESTDIR}${MESON_INSTALL_PREFIX}/$2/dock.theme"

0 commit comments

Comments
 (0)