Skip to content

Commit f7fda41

Browse files
committed
Initial commit: Match cursors folder structure to upstream with yaru specific modifications
1 parent 2e434da commit f7fda41

File tree

7 files changed

+16125
-9629
lines changed

7 files changed

+16125
-9629
lines changed

icons/src/cursors/cursorgen.py

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
#!/usr/bin/env python3
2+
3+
import os
4+
import math
5+
import subprocess
6+
import logging
7+
8+
# Configure logging
9+
logging.basicConfig(level=logging.DEBUG, format='%(levelname)s: %(message)s')
10+
11+
# Define the nominal size and a dictionary for cursor names and their hotspots (24x24)
12+
nominal_size = 24
13+
cursors = {
14+
"alias": (10, 10),#
15+
"all-resize": (11, 11),#
16+
"all-scroll": (11, 11),#
17+
"cell": (11, 11),#
18+
"col-resize": (11, 11),#
19+
"context-menu": (2, 1),#
20+
"copy": (2, 1),#
21+
"crosshair": (11, 11),#
22+
"default": (3, 3),#
23+
"e-resize": (11, 11),#
24+
"ew-resize": (11, 11),#
25+
"grab": (11, 2),#
26+
"grabbing": (11, 9),#
27+
"help": (11, 19),#
28+
"ne-resize": (11, 11),#
29+
"nesw-resize": (11, 11),#
30+
"no-drop": (2, 1),#
31+
"not-allowed": (11, 11),#
32+
"n-resize": (11, 11),#
33+
"ns-resize": (11, 11),#
34+
"nw-resize": (11, 11),#
35+
"nwse-resize": (11, 11),#
36+
"pointer": (8, 3),#
37+
"progress": {"hotspot": (2, 1), "frames": 60, "duration": 16},#
38+
"row-resize": (11, 11),#
39+
"se-resize": (11, 11),#
40+
"s-resize": (11, 11),#
41+
"sw-resize": (11, 11),#
42+
"text": (10, 11),#
43+
"vertical-text": (11, 10),#
44+
"text": (10, 11),#
45+
"wait": {"hotspot": (11, 11), "frames": 60, "duration": 16},#
46+
"w-resize": (11, 11),#
47+
"zoom-in": (10, 10),#
48+
"zoom-out": (10, 10),#
49+
"X_cursor": (11, 11)
50+
}
51+
52+
# Define the sizes we want to scale to
53+
sizes = [24, 30, 36, 48, 72, 96]
54+
55+
# Base directories
56+
png_dir = './pngs' # Updated to use "pngs"
57+
output_dir = '../../Yaru/cursors/'
58+
59+
# Function to generate .in file content
60+
def generate_in_file_content(cursor_name, cursor_info):
61+
in_content = []
62+
is_animated = isinstance(cursor_info, dict)
63+
64+
frame_range = range(1, cursor_info["frames"] + 1) if is_animated else [1]
65+
hotspot = cursor_info["hotspot"] if is_animated else cursor_info
66+
67+
for frame in frame_range:
68+
for size in sizes:
69+
file_name = f"{cursor_name}_{frame:04d}.png" if is_animated else f"{cursor_name}.png"
70+
png_file_relative = f"pngs/{size}x{size}/{file_name}"
71+
png_file = os.path.join(png_dir, f"{size}x{size}", file_name)
72+
73+
if not os.path.exists(png_file):
74+
logging.error(f"PNG file not found: {png_file}")
75+
continue
76+
77+
hotspot_x = math.floor(hotspot[0] * size / nominal_size)
78+
hotspot_y = math.floor(hotspot[1] * size / nominal_size)
79+
80+
entry = f"{size} {hotspot_x} {hotspot_y} {png_file_relative}"
81+
if is_animated:
82+
entry += f" {cursor_info['duration']}"
83+
in_content.append(entry + "\n")
84+
85+
return ''.join(in_content)
86+
87+
# Function to generate all .in files and call xcursorgen
88+
def generate_cursors():
89+
for cursor_name, cursor_info in cursors.items():
90+
logging.info(f"Processing cursor: {cursor_name}")
91+
92+
# Generate the full .in file content
93+
in_file_content = generate_in_file_content(cursor_name, cursor_info)
94+
in_file_path = os.path.join(png_dir, f'{cursor_name}.in')
95+
96+
# Write the .in file in ./pngs/ directory
97+
try:
98+
with open(in_file_path, 'w') as in_file:
99+
in_file.write(in_file_content)
100+
logging.info(f"Generated .in file: {in_file_path}")
101+
except Exception as e:
102+
logging.error(f"Error writing .in file: {in_file_path} - {str(e)}")
103+
continue
104+
105+
# Call xcursorgen to generate the cursor file
106+
cursor_output = os.path.join(output_dir, cursor_name)
107+
command = ['xcursorgen', in_file_path, cursor_output]
108+
logging.debug(f"Running command: {' '.join(command)}")
109+
try:
110+
subprocess.run(command, check=True)
111+
logging.info(f"Generated cursor: {cursor_output}")
112+
except subprocess.CalledProcessError as e:
113+
logging.error(f"xcursorgen failed for {cursor_name}: {str(e)}")
114+
115+
if __name__ == "__main__":
116+
# Ensure output directory exists
117+
if not os.path.exists(output_dir):
118+
logging.info(f"Creating output directory: {output_dir}")
119+
os.makedirs(output_dir)
120+
121+
# Call the main function to generate cursors
122+
generate_cursors()
123+

icons/src/cursors/pngs/make-w32.sh

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/bin/sh
2+
3+
THEME=Yaru
4+
DIR="../../.."
5+
6+
# $@ is for the caller to be able to supply arguments to anicursorgen (-s, in particular)
7+
GEN=../anicursorgen.py\ "$@"
8+
mkdir -p $DIR/$THEME/cursors
9+
${GEN} default$s.in $DIR/$THEME/cursors/default.cur
10+
${GEN} help$s.in $DIR/$THEME/cursors/help.cur
11+
${GEN} pointer$s.in $DIR/$THEME/cursors/pointer.cur
12+
${GEN} context-menu$s.in $DIR/$THEME/cursors/context-menu.cur
13+
${GEN} progress$s.in $DIR/$THEME/cursors/progress.ani
14+
${GEN} wait$s.in $DIR/$THEME/cursors/wait.ani
15+
${GEN} cell$s.in $DIR/$THEME/cursors/cell.cur
16+
${GEN} crosshair$s.in $DIR/$THEME/cursors/crosshair.cur
17+
${GEN} text$s.in $DIR/$THEME/cursors/text.cur
18+
${GEN} vertical-text$s.in $DIR/$THEME/cursors/vertical-text.cur
19+
${GEN} alias$s.in $DIR/$THEME/cursors/alias.cur
20+
${GEN} copy$s.in $DIR/$THEME/cursors/copy.cur
21+
${GEN} no-drop$s.in $DIR/$THEME/cursors/no-drop.cur
22+
${GEN} move$s.in $DIR/$THEME/cursors/move.cur
23+
${GEN} not-allowed$s.in $DIR/$THEME/cursors/not-allowed.cur
24+
${GEN} grab$s.in $DIR/$THEME/cursors/grab.cur
25+
${GEN} grabbing$s.in $DIR/$THEME/cursors/grabbing.cur
26+
${GEN} all-scroll$s.in $DIR/$THEME/cursors/all-scroll.cur
27+
${GEN} col-resize$s.in $DIR/$THEME/cursors/col-resize.cur
28+
${GEN} row-resize$s.in $DIR/$THEME/cursors/row-resize.cur
29+
${GEN} n-resize$s.in $DIR/$THEME/cursors/n-resize.cur
30+
${GEN} s-resize$s.in $DIR/$THEME/cursors/s-resize.cur
31+
${GEN} e-resize$s.in $DIR/$THEME/cursors/e-resize.cur
32+
${GEN} w-resize$s.in $DIR/$THEME/cursors/w-resize.cur
33+
${GEN} ne-resize$s.in $DIR/$THEME/cursors/ne-resize.cur
34+
${GEN} nw-resize$s.in $DIR/$THEME/cursors/nw-resize.cur
35+
${GEN} sw-resize$s.in $DIR/$THEME/cursors/sw-resize.cur
36+
${GEN} se-resize$s.in $DIR/$THEME/cursors/se-resize.cur
37+
${GEN} ew-resize$s.in $DIR/$THEME/cursors/ew-resize.cur
38+
${GEN} ns-resize$s.in $DIR/$THEME/cursors/ns-resize.cur
39+
${GEN} nesw-resize$s.in $DIR/$THEME/cursors/nesw-resize.cur
40+
${GEN} nwse-resize$s.in $DIR/$THEME/cursors/nwse-resize.cur
41+
${GEN} zoom-in$s.in $DIR/$THEME/cursors/zoom-in.cur
42+
${GEN} zoom-out$s.in $DIR/$THEME/cursors/zoom-out.cur

0 commit comments

Comments
 (0)