initial commit

This commit is contained in:
mxhagen 2025-05-30 17:55:38 +02:00
commit 0b130f3ba9
46 changed files with 334 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
cursors

19
LICENSE Normal file
View File

@ -0,0 +1,19 @@
MIT License
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

63
README.md Normal file
View File

@ -0,0 +1,63 @@
# sqr-xcursor
a simple, complete, 32x32, square shaped x11 cursor theme.
## Preview
![preview image](./preview.png)
## Usage
to build and install the cursor theme, `xcursorgen` is required.
you can then use the provided shell scripts:
1. create the cursor files from the png images:
```sh
# hotspot at pixel 15,15 (center), 50ms per animation frame
cd src && ./generate.sh 15 15 50
```
2. create links for some other cursors for completeness:
```sh
cd src && ./create-links.sh
```
3. install the theme
- either system-wide:
```sh
sudo mkdir -p /usr/share/icons/sqr-xcursor && sudo cp cursors $_ -r
```
- or just for the current user:
```sh
mkdir -p $XDG_DATA_HOME/icons/sqr-xcursor && cp cursors $_ -r
```
4. use the theme:
in regular desktop environments, selecting it in your settings should suffice.
without a desktop environment, setting a `default` in the `icons` directory
(whether system-wide or user-specific)
should work:
```sh
# system-wide:
sudo mkdir -p /usr/share/icons/default && \
sudo printf "\n[Icon Theme]\nInherits=sqr-xcursor\n" >> $_/index.theme
# or user-only:
mkdir -p $XDG_DATA_HOME/icons/default && \
printf "\n[Icon Theme]\nInherits=sqr-xcursor\n" >> $_/index.theme
```
### **you will need to restart your xsession after this (log out and back in)**
if issues still arise, setting the cursor theme in your `.config/gtk-3.0/settings.ini`
might also be required/help:
```ini
[Settings]
gtk-cursor-theme-name=sqr-xcursor
gtk-cursor-theme-size=32
```

9
index.theme Normal file
View File

@ -0,0 +1,9 @@
[Icon Theme]
Name=Sqr
Comment=A minimalist Square Cursor
Inherits=WhiteSur cursors,Adwaita,hicolor
Directories=cursors
[cursors]
Size=32
Type=Fixed

BIN
preview.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

143
src/create-links.sh Normal file
View File

@ -0,0 +1,143 @@
#!/usr/bin/env bash
dir="../cursors"
main() {
parse_args $@
cd "$dir"
set -e
ln -s frame all-scroll
ln -s default arrow
ln -s downleft bottom_left_corner
ln -s downright bottom_right_corner
ln -s down bottom_side
ln -s default cell
ln -s default center_ptr
ln -s forbidden circle
ln -s active closedhand
ln -s cross colorpicker
ln -s leftright col-resize
ln -s plus copy
ln -s forbidden crossed_circle
ln -s default crosshair
ln -s plus dnd-copy
ln -s active dnd-move
ln -s forbidden dnd-no-drop
ln -s active dnd-none
ln -s down down-arrow
ln -s default draft
ln -s right e-resize
ln -s leftright ew-resize
ln -s updownleftright fleur
ln -s active grab
ln -s active grabbing
ln -s wait half-busy
ln -s active hand1
ln -s active hand2
ln -s leftright h_double_arrow
ln -s question-mark help
ln -s text ibeam
ln -s left left-arrow
ln -s default left_ptr
ln -s question-mark left_ptr_help
ln -s wait left_ptr_watch
ln -s left left-side
ln -s alias link
ln -s downleft ll_angle
ln -s downright lr_angle
ln -s active move
ln -s upright ne-resize
ln -s downleft-upright nesw-resize
ln -s forbidden-active no-drop
ln -s forbidden not-allowed
ln -s up n-resize
ln -s updown ns-resize
ln -s upleft nw-resize
ln -s upleft-downright nwse-resize
ln -s active openhand
ln -s active pointer
ln -s active pointing_hand
ln -s wait progress
ln -s question-mark question_arrow
ln -s right right-arrow
ln -s default right_ptr
ln -s right right_side
ln -s updown row-resize
ln -s leftright sb_h_double_arrow
ln -s updown sb_v_double_arrow
ln -s downright se-resize
ln -s updownleftright size_all
ln -s downleft-upright size_bdiag
ln -s upleft-downright size_fdiag
ln -s leftright size_hor
ln -s updown size_ver
ln -s leftright split_h
ln -s updown split_v
ln -s down s-resize
ln -s downleft sw-resize
ln -s upleft top_left_corner
ln -s upright top_right_corner
ln -s up top_side
ln -s upleft ul_angle
ln -s up up-arrow
ln -s upright ur_angle
ln -s updown v_double_arrow
ln -s wait watch
ln -s question-mark whats_this
ln -s left w-resize
ln -s cross x-cursor
ln -s text xterm
ln -s plus zoom-in
ln -s minus zoom-out
set +e
info "done with all cursors. created links can be found in \`$dir\`."
}
usage() {
echo ""
echo "usage: $scriptname"
echo ""
echo "generate a predefined set of links to xcursor files easily."
echo ""
echo "options: hot_x, hot_y the offset of the cursor hotspot from the top-left pixel"
echo " frametime time in ms for each frame, defaults to 50, only affects animations"
echo ""
echo "flags: -h, --help display this message and exit"
echo ""
}
parse_args() {
scriptname=$(basename "$0")
# sanity check that cursors even exist
if [[ ! -d "$dir" ]]; then
error "$dir not found. generate cursor files first before creating symlinks."
exit 1
elif [[ -z $(ls "$dir"/*) ]]; then
error "$dir seems to be empty. generate cursor files first before creating symlinks."
exit 1
fi
# parse flags
shift
while [[ $# -gt 0 ]]; do
case "$1" in
-h|--help) usage ; exit 0 ;;
esac
shift
done
}
info() { echo "[info] " "$1" >&2 ;}
error() { echo "[error]" "$1" >&2 ;}
# run main, passing on all args
main $@

99
src/generate.sh Normal file
View File

@ -0,0 +1,99 @@
#!/usr/bin/env bash
out_dir="../cursors"
main() {
parse_args $@
# create output directory
mkdir -p "$out_dir" >/dev/null
# for simple png cursors
for file in ./img/*.png; do
get_image_size "$file"
name=$(basename "$file" .png)
echo "$size $hot_x $hot_y $file" | xcursorgen > "$out_dir/$name"
info "done with regular cursor $name..."
done
# for folders of png frames
for name in $(find ./img -mindepth 1 -maxdepth 1 -type d); do
content=""
for file in "$name"/*.png; do
get_image_size "$file"
content+="$size $hot_x $hot_x $file $frametime\n"
done
name=$(basename "$name")
printf "$content" | xcursorgen > "$out_dir/$name"
info "done with animated cursor $name..."
done
echo ""
info "done with all cursors. outputted files can be found in \`$out_dir\`."
}
get_image_size() {
if [[ $(file "$1") =~ ([0-9]+)\ x\ ([0-9]+) ]]; then
size=${BASH_REMATCH[1]}
else
error "failed to read image dimensions from command \`file \"$1\"\`."
exit 1
fi
}
usage() {
echo ""
echo "usage: $scriptname <hot_x> <hot_y> [frametime?] [FLAGS...]"
echo ""
echo "generate an .cursor theme file. iterates all png files in \`./img\`."
echo "named folders of png files are used as frames for animated cursors. (alphabetical order)"
echo ""
echo "options: hot_x, hot_y the offset of the cursor hotspot from the top-left pixel"
echo " frametime time in ms for each frame, defaults to 50, only affects animations"
echo ""
echo "flags: -h, --help display this message and exit"
echo ""
}
parse_args() {
scriptname=$(basename "$0")
if ! command -v xcursorgen >/dev/null; then
error "missing required dependency \`xcursorgen\`. install it and try again."
exit 1
fi
if [[ $# -lt 2 ]] || [[ $# -gt 3 ]]; then
error "invalid number of arguments. expected 2-3, got $#."
usage >&2
exit 1
fi
# parse options
hot_x="$1"
hot_y="$2"
frametime=50
if [[ -n "$3" ]]; then
frametime="$3"
fi
# parse flags
shift
while [[ $# -gt 0 ]]; do
case "$1" in
-h|--help) usage ; exit 0 ;;
esac
shift
done
}
info() { echo "[info] " "$1" >&2 ;}
error() { echo "[error]" "$1" >&2 ;}
# run main, passing on all args
main $@

BIN
src/img/active.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 266 B

BIN
src/img/alias.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 319 B

BIN
src/img/context-menu.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 317 B

BIN
src/img/cross.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 321 B

BIN
src/img/default.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 254 B

BIN
src/img/down.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 298 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 322 B

BIN
src/img/downleft.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 290 B

BIN
src/img/downright.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 285 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 357 B

BIN
src/img/forbidden.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 353 B

BIN
src/img/frame.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 331 B

BIN
src/img/left.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 285 B

BIN
src/img/leftright.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 304 B

BIN
src/img/minus.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 303 B

BIN
src/img/pirate.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 458 B

BIN
src/img/plus.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 325 B

BIN
src/img/question-mark.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 340 B

BIN
src/img/right.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 289 B

BIN
src/img/text.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 283 B

BIN
src/img/up.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 287 B

BIN
src/img/updown.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 322 B

BIN
src/img/updownleftright.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 364 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 321 B

BIN
src/img/upleft.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 292 B

BIN
src/img/upright.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 291 B

BIN
src/img/vertical-text.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 267 B

BIN
src/img/wait/wait_00.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 265 B

BIN
src/img/wait/wait_01.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 264 B

BIN
src/img/wait/wait_02.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 265 B

BIN
src/img/wait/wait_03.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 265 B

BIN
src/img/wait/wait_04.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 267 B

BIN
src/img/wait/wait_05.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 265 B

BIN
src/img/wait/wait_06.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 265 B

BIN
src/img/wait/wait_07.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 265 B

BIN
src/img/wait/wait_08.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 266 B

BIN
src/img/wait/wait_09.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 266 B

BIN
src/img/wait/wait_10.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 266 B

BIN
src/img/wait/wait_11.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 267 B