Skip to content

Commit

Permalink
My own left-handed patch for Bibata Cursor
Browse files Browse the repository at this point in the history
  • Loading branch information
unclechu committed Feb 1, 2022
1 parent 050ef93 commit a8b44c5
Show file tree
Hide file tree
Showing 2 changed files with 151 additions and 1 deletion.
64 changes: 63 additions & 1 deletion user-specific/mouse-cursor/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,74 @@
{ pkgs, ... }:
let
inherit (import ../../constants.nix) wenzelUserName;

left-handed-bibata-cursors = pkgs.bibata-cursors.overrideAttrs (srcAttrs: {
nativeBuildInputs = srcAttrs.nativeBuildInputs ++ [
pkgs.findutils
pkgs.gnugrep
pkgs.perl
pkgs.imagemagick
];

patches = [
./flip-x-hot-points-for-left-handed-cursors.patch
];

buildPhase = ''
mkdir bitmaps
unzip $bitmaps -d bitmaps
rm -rf themes
(
set -uo pipefail || exit
images_to_flip=$(
cat builder/src/constants.py \
| perl -nE 'if (/^horizontally_flipped/) {$x=1;next}; print if $x' \
| perl -nE '$x=1 if /^]/; print unless $x' \
| sed -e 's/#.*//' -e 's/[," ]//g' \
| grep -v '^$'
)
static_images_to_flip=$(grep '\.png$' <<< "$images_to_flip")
animated_images_to_flip=$(grep -v '\.png$' <<< "$images_to_flip")
readarray -t static_images_to_flip <<< "$static_images_to_flip"
readarray -t animated_images_to_flip <<< "$animated_images_to_flip"
cd bitmaps
themes=$(ls)
readarray -t themes <<< "$themes"
for theme in "''${themes[@]}"; do
(
cd -- "$theme"
>&2 printf 'Horizontally flipping static images for "%s" theme...\n' "$theme"
for image in "''${static_images_to_flip[@]}"; do
(set -x && convert -flop -- "$image" "$image")
done
>&2 printf 'Horizontally flipping animated frames for "%s" theme...\n' "$theme"
for file_prefix in "''${animated_images_to_flip[@]}"; do
files=$(find -name "''${file_prefix}*.png")
readarray -t files <<< "$files"
for image in "''${files[@]}"; do
(set -x && convert -flop -- "$image" "$image")
done
done
)
done
)
cd builder && make build_unix
'';
});
in
{
home-manager.users.${wenzelUserName} = {
xsession.pointerCursor = {
name = "Bibata-Original-Ice";
package = pkgs.bibata-cursors;
package = left-handed-bibata-cursors;
defaultCursor = "left_ptr";
size = 24;
};
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
diff --git a/builder/src/constants.py b/builder/src/constants.py
index b8bd14b7..45f8cd01 100644
--- a/builder/src/constants.py
+++ b/builder/src/constants.py
@@ -1,7 +1,7 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

-from typing import Dict
+from typing import Dict, List

# Info
AUTHOR = "Kaiz Khatri"
@@ -80,6 +80,74 @@ X_CURSORS_CFG: Dict[str, Dict[str, int]] = {
"wait": {"xhot": 100, "yhot": 100},
}

+horizontally_flipped: List[str] = [
+ ##########
+ # Static #
+ ##########
+ # "bottom_left_corner.png", # must stay as-is
+ # "bottom_right_corner.png", # must stay as-is
+ # "bottom_side.png", # must stay as-is
+ # "bottom_tee.png", # must stay as-is
+ "center_ptr.png",
+ "circle.png",
+ "context-menu.png",
+ "copy.png",
+ "cross.png",
+ "crossed_circle.png",
+ "crosshair.png",
+ "dnd_no_drop.png",
+ "dnd-ask.png",
+ "dnd-copy.png",
+ "dnd-link.png",
+ "dnd-move.png",
+ "dotbox.png",
+ # "fd_double_arrow.png", # must stay as-is
+ "grabbing.png",
+ "hand1.png",
+ "hand2.png",
+ "left_ptr.png",
+ # "left_side.png", # must stay as-is
+ # "left_tee.png", # must stay as-is
+ "link.png",
+ # "ll_angle.png", # must stay as-is
+ # "lr_angle.png", # must stay as-is
+ "move.png",
+ "pencil.png",
+ "plus.png",
+ "pointer-move.png",
+ # "question_arrow.png", # must stay as-is
+ "right_ptr.png",
+ # "right_side.png", # must stay as-is
+ # "right_tee.png", # must stay as-is
+ # "sb_down_arrow.png", # must stay as-is
+ # "sb_h_double_arrow.png", # must stay as-is
+ # "sb_left_arrow.png", # must stay as-is
+ # "sb_right_arrow.png", # must stay as-is
+ # "sb_up_arrow.png", # must stay as-is
+ # "sb_v_double_arrow.png", # must stay as-is
+ "tcross.png",
+ # "top_left_corner.png", # must stay as-is
+ # "top_right_corner.png", # must stay as-is
+ # "top_side.png", # must stay as-is
+ # "top_tee.png", # must stay as-is
+ # "ul_angle.png", # must stay as-is
+ # "ur_angle.png", # must stay as-is
+ "vertical-text.png",
+ # "wayland-cursor.png", # must stay as-is
+ "X_cursor.png",
+ "xterm.png",
+ "zoom-in.png",
+ "zoom-out.png",
+ ############
+ # Animated #
+ ############
+ "left_ptr_watch",
+ "wait", # makes it be counter-clockwise, the same as "left_ptr_watch"
+]
+
+for key in horizontally_flipped:
+ X_CURSORS_CFG[key]["xhot"] = 200 - X_CURSORS_CFG[key]["xhot"]
+
WIN_CURSORS_CFG: Dict[str, Dict[str, str]] = {
##########
# Static #

0 comments on commit a8b44c5

Please sign in to comment.