Coder Social home page Coder Social logo

clickgen's Introduction

Clickgen

ci code coverage

Clickgen is cross-platform python library for building XCursor and Windows Cursors.

Clickgen's core functionality is heavily inspired by quantum5/win2xcur from v2.0.0 and onwards.

Notices

shoutout-sponsors

Note The project's success depends on sponsorships. Meeting sponsorship goals for ful1e5 GitHub Account will drive new releases and ongoing development.

  • 2024-05-24: Clickgen now allows cursor bitmap re-canvasing by specifying size using the cursor_size:canvas_size format. See changelog-05212024
  • 2023-08-23: ctgen CLI supports .json and .yaml/.yml as configuration file.
  • 2023-08-17: Cursor size settings moved to [cursors.fallback_settings] in config. See changelog-08172023
  • 2022-06-15: Docker Image support deprecated due to cross-platform compatibility.
  • 2022-07-09: ⚠️ All the functionality and modules are removed from older versions in v2.0.0. I will be restricting any updates to the >=v1.2.0 versions to security updates and hotfixes. Check updated documentations for building cursors from API and CLIs usage.

Requirements

Install

pip3 install clickgen

Note Distributions' packages are not affiliated with clickgen developers. If you encounter any issues with the incorrect installation, you should contact the package maintainer first.

Arch Linux

Usage

clickgen CLI

Linux Format (XCursor)

For example, if you have to build ponter.png file to Linux Format:

clickgen samples/pngs/pointer.png -x 10 -y 10 -s 22 24 32 -p x11

You also build animated Xcursor by providing multiple png files to argument and animation delay with -d:

clickgen samples/pngs/wait-001.png samples/pngs/wait-001.png -d 3 -x 10 -y 10 -s 22 24 32 -p x11

Windows Formats (.cur and .ani)

To build ponter.png file to Windows Format (.cur):

Warning: Windows Animated Cursor only support single size.

clickgen samples/pngs/pointer.png -x 10 -y 10 -s 32 -p windows

You can also specify the size in the size:canvas_size format to enable canvasing:

clickgen samples/pngs/pointer.png -x 10 -y 10 -s 20:32 -p windows

For animated Windows Cursor (.ani):

clickgen samples/pngs/wait-001.png samples/pngs/wait-001.png -d 3 -x 10 -y 10 -s 32 -p windows

For more information, run clickgen --help.

ctgen CLI

This CLI allow you to generate Windows and Linux Cursor themes from config (.toml.yml,and .json) files.

ctgen sample/sample.json
ctgen sample/sample.toml
ctgen sample/sample.yaml

You also provide multiple theme configuration file once as following:

ctgen sample/sample.toml sample/sample.json

Override theme's name of theme with -n option:

ctgen sample/sample.toml -n "New Theme"

You can run ctgen --help to view all available options and you also check samples directory for more information.

API Examples

Static XCursor

from clickgen.parser import open_blob
from clickgen.writer import to_x11

with open("samples/pngs/pointer.png", "rb") as p:
    cur = open_blob([p.read()], hotspot=(50, 50))

    # save X11 static cursor
    xresult = to_x11(cur.frames)
    with open("xtest", "wb") as o:
        o.write(xresult)

Animated XCursor

from glob import glob
from typing import List

from clickgen.parser import open_blob
from clickgen.writer import to_x11

# Get .png files from directory
fnames = glob("samples/pngs/wait-*.png")
pngs: List[bytes] = []

# Reading as bytes
for f in sorted(fnames):
    with open(f, "rb") as p:
        pngs.append(p.read())

cur = open_blob(pngs, hotspot=(100, 100))

# save X11 animated cursor
result = to_x11(cur.frames)
with open("animated-xtest", "wb") as o:
    o.write(result)

Static Windows Cursor (.cur)

from clickgen.parser import open_blob
from clickgen.writer import to_win

with open("samples/pngs/pointer.png", "rb") as p:
    cur = open_blob([p.read()], hotspot=(50, 50))

    # save Windows static cursor
    ext, result = to_win(cur.frames)
    with open(f"test{ext}", "wb") as o:
        o.write(result)

Animated Windows Cursor (.ani)

from glob import glob
from typing import List

from clickgen.parser import open_blob
from clickgen.writer import to_win

# Get .png files from directory
fnames = glob("samples/pngs/wait-*.png")
pngs: List[bytes] = []

# Reading as bytes
for f in sorted(fnames):
    with open(f, "rb") as p:
        pngs.append(p.read())

cur = open_blob(pngs, hotspot=(100, 100))

# save Windows animated cursor
ext, result = to_win(cur.frames)
with open(f"test-ani{ext}", "wb") as o:
    o.write(result)

Documentation

Check wiki for documentation.

clickgen's People

Contributors

cybertailor avatar dependabot-preview[bot] avatar dependabot[bot] avatar ful1e5 avatar monosans avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

clickgen's Issues

AUR Build is failing

OS: Arch Linux
PKGBUILD

Build is failing with:

ERROR Missing dependencies:
	setuptools>=40.9.0
	jaraco.text -> inflect -> pydantic>=1.9.1 -> typing-extensions>=4.2.0
==> ERROR: A failure occurred in build().
    Aborting...

while all these dependencies are installed with latest version

Fix 8 Maintainability, 1 Complexity issues in clickgen\__main__.py

CodeFactor found multiple issues:

Unnecessary "elif" after "return"

clickgen_main_.py:80

Unnecessary "else" after "return"

clickgen_main_.py:59

Redefining argument with the local name 'config'

clickgen_main_.py:54

The if statement can be replaced with 'return bool(test)'

clickgen_main_.py:59

Comparison to False should be 'not expr'

clickgen_main_.py:116
clickgen_main_.py:116
clickgen_main_.py:80

Comparison to True should be just 'expr'

clickgen_main_.py:82

Complex Method

clickgen_main_.py:90-192

No module named 'clickgen.libs'

I'd be happy to update the AUR package to 2.1.5, however...

❯ ctgen --help
Traceback (most recent call last):
  File "/usr/bin/ctgen", line 5, in <module>
    from clickgen.scripts.ctgen import main
  File "/usr/lib/python3.11/site-packages/clickgen/scripts/ctgen.py", line 16, in <module>
    from clickgen.configparser import parse_config_file
  File "/usr/lib/python3.11/site-packages/clickgen/configparser.py", line 12, in <module>
    from clickgen.libs.colors import print_warning
ModuleNotFoundError: No module named 'clickgen.libs'

Am I missing something?

`PNGProvider` regex fail to get 'png' or 'png sequence'

Problem

clickgen.util.PNGProvider get() method fail to retrieve pngs, If key matches to similarly named files.

For example, Retrieve cross from these bitmaps 👇 gave the same list.

cross.png
crossed_circle.png
crosshair-01.png
crosshair-02.png

.ani not working

Hi so i'm creating a .ani as you are showing:
`
cur = open_blob(self.frames, hotspot=(0, 0))

    # save Windows animated cursor
    ext, result = to_win(cur.frames)
    with open(f"test-ani{ext}", "wb") as o:
        o.write(result) # between in your readme a typo is introduced before result

`
But the file created isn't usable. i can display one frame, by retriving the first frame of the .ani on my app, but the icon is the default file on the file explorer. And when i'm changing the cursor i can see in the registry that it was changed. But it still display the precedent one.

even using your wait-00x.png sample it doesn't works

But for .cur everything works fine :D

Resize Cursor wrong implementation (KDE Hex Cursor)

Description of the problem

Some KDE Cursors using hex links. Verticle Resize is one of them. Look like it has the wrong implementation with Horizontal Resize.

How has this issue affected you? What are you trying to accomplish?

Resizing rectangular screenshot in Spectacle(KDE Screenshot app).

Logs or Screenshots: (optional)

Issue Video: imgur

Your Environment

Software Name/Version
Operating System Kubuntu 20.04

support Windows and macOS

OSError: dlopen(apple_cursor-main/builder/venv/lib/python3.8/site-packages/clickgen-1.1.8-py3.8.egg/clickgen/xcursorgen.so, 6): no suitable image found. Did find:
apple_cursor-main/builder/venv/lib/python3.8/site-packages/clickgen-1.1.8-py3.8.egg/clickgen/xcursorgen.so: unknown file type, first eight bytes: 0x7F 0x45 0x4C 0x46 0x02 0x01 0x01 0x00
apple_cursor-main/builder/venv/lib/python3.8/site-packages/clickgen-1.1.8-py3.8.egg/clickgen/xcursorgen.so: unknown file type, first eight bytes: 0x7F 0x45 0x4C 0x46 0x02 0x01 0x01 0x00

Wrong cursor icons on Windows

When I update clickgen to the latest version and generate a new cursor theme, the cursor icons are wrong.

image

I see some different from install.inf between old and new themes.

Old

[Version]
signature="$CHICAGO$"
Breeze by the KDE VDG
https://github.com/akiirui/breeze-for-windows

[DefaultInstall]
CopyFiles = Scheme.Cur, Scheme.Txt
AddReg    = Scheme.Reg

[DestinationDirs]
Scheme.Cur = 10,"%CUR_DIR%"
Scheme.Txt = 10,"%CUR_DIR%"

[Scheme.Reg]
HKCU,"Control Panel\Cursors\Schemes","%SCHEME_NAME%",,"%10%\%CUR_DIR%\%pointer%,%10%\%CUR_DIR%\%help%,%10%\%CUR_DIR%\%work%,%10%\%CUR_DIR%\%busy%,%10%\%CUR_DIR%\%Cross%,%10%\%CUR_DIR%\%Text%,%10%\%CUR_DIR%\%Hand%,%10%\%CUR_DIR%\%Unavailiable%,%10%\%CUR_DIR%\%Vert%,%10%\%CUR_DIR%\%Horz%,%10%\%CUR_DIR%\%Dgn1%,%10%\%CUR_DIR%\%Dgn2%,%10%\%CUR_DIR%\%move%,%10%\%CUR_DIR%\%alternate%,%10%\%CUR_DIR%\%link%"

; -- Installed files

[Scheme.Cur]
"Work.ani"
"Busy.ani"
"Default.cur"
"Help.cur"
"Link.cur"
"Move.cur"
"Diagonal_2.cur"
"Vertical.cur"
"Horizontal.cur"
"Diagonal_1.cur"
"Handwriting.cur"
"Cross.cur"
"IBeam.cur"
"Unavailiable.cur"
"Alternate.cur"

[Strings]
CUR_DIR           = "Cursors\Breeze Cursors"
SCHEME_NAME       = "Breeze Cursors"
pointer           = "Default.cur"
help              = "Help.cur"
work              = "Work.ani"
busy              = "Busy.ani"
cross             = "Cross.cur"
text              = "IBeam.cur"
hand              = "Handwriting.cur"
unavailiable      = "Unavailiable.cur"
vert              = "Vertical.cur"
horz              = "Horizontal.cur"
dgn1              = "Diagonal_1.cur"
dgn2              = "Diagonal_2.cur"
move              = "Move.cur"
alternate         = "Alternate.cur"
link              = "Link.cur"

New


; ===========================================================
; Auto-Generated File
; ===========================================================
; This file has been automatically generated by a tool
; called 'clickgen'. For more information,
; visit: https://www.github.com/ful1e5/clickgen
; ===========================================================


; Breeze Cursors
; Breeze by the KDE VDG https://github.com/akiirui/breeze-for-windows

[Version]
signature="$CHICAGO$"
Breeze by the KDE VDG

[DefaultInstall]
CopyFiles = Scheme.Cur
AddReg    = Scheme.Reg,Wreg

[DestinationDirs]
Scheme.Cur = 10,"%CUR_DIR%"

[Scheme.Reg]
HKCU,"Control Panel\Cursors\Schemes","%SCHEME_NAME%",,"%10%\%CUR_DIR%\%help%,%10%\%CUR_DIR%\%work%,%10%\%CUR_DIR%\%busy%,%10%\%CUR_DIR%\%cross%,%10%\%CUR_DIR%\%handwriting%,%10%\%CUR_DIR%\%move%,%10%\%CUR_DIR%\%alternate%,%10%\%CUR_DIR%\%link%,%10%\%CUR_DIR%\%diagonal_1%,%10%\%CUR_DIR%\%horizontal%,%10%\%CUR_DIR%\%vertical%,%10%\%CUR_DIR%\%ibeam%,%10%\%CUR_DIR%\%default%,%10%\%CUR_DIR%\%diagonal_2%,%10%\%CUR_DIR%\%unavailiable%"

[Wreg]
HKCU,"Control Panel\Cursors",,0x00020000,"%SCHEME_NAME%"
HKCU,"Control Panel\Cursors",Help,0x00020000,"%10%\%CUR_DIR%\%help%"
HKCU,"Control Panel\Cursors",AppStarting,0x00020000,"%10%\%CUR_DIR%\%work%"
HKCU,"Control Panel\Cursors",Wait,0x00020000,"%10%\%CUR_DIR%\%busy%"
HKCU,"Control Panel\Cursors",crosshair,0x00020000,"%10%\%CUR_DIR%\%cross%"
HKCU,"Control Panel\Cursors",precisionhair,0x00020000,"%10%\%CUR_DIR%\%cross%"
HKCU,"Control Panel\Cursors",NWPen,0x00020000,"%10%\%CUR_DIR%\%handwriting%"
HKCU,"Control Panel\Cursors",Grab,0x00020000,"%10%\%CUR_DIR%\%move%"
HKCU,"Control Panel\Cursors",SizeAll,0x00020000,"%10%\%CUR_DIR%\%move%"
HKCU,"Control Panel\Cursors",UpArrow,0x00020000,"%10%\%CUR_DIR%\%alternate%"
HKCU,"Control Panel\Cursors",Hand,0x00020000,"%10%\%CUR_DIR%\%link%"
HKLM,"SOFTWARE\Microsoft\Windows\CurrentVersion\Runonce\Setup\","",,"rundll32.exe shell32.dll,Control_RunDLL main.cpl @0,1"

[Scheme.Cur]
Help.cur
Work.ani
Busy.ani
Cross.cur
Handwriting.cur
Move.cur
Alternate.cur
Link.cur
Diagonal_1.cur
Horizontal.cur
Vertical.cur
IBeam.cur
Default.cur
Diagonal_2.cur
Unavailiable.cur

[Scheme.Txt]

[Strings]
CUR_DIR             = "Cursors\Breeze Cursors"
SCHEME_NAME         = "Breeze Cursors"
help                = "Help.cur"
work                = "Work.ani"
busy                = "Busy.ani"
cross               = "Cross.cur"
handwriting         = "Handwriting.cur"
move                = "Move.cur"
alternate           = "Alternate.cur"
link                = "Link.cur"
diagonal_1          = "Diagonal_1.cur"
horizontal          = "Horizontal.cur"
vertical            = "Vertical.cur"
ibeam               = "IBeam.cur"
default             = "Default.cur"
diagonal_2          = "Diagonal_2.cur"
unavailiable        = "Unavailiable.cur"

Copy the old install.inf to new theme and install it, works fine.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.