Skip to content
This repository has been archived by the owner on Feb 15, 2025. It is now read-only.

Commit

Permalink
[Dev] Optimize scripts for installing
Browse files Browse the repository at this point in the history
optimized the scripts to install more gracefully.

Also update the README accordingly for installing from released package
  • Loading branch information
philia897 committed Sep 27, 2024
1 parent f9a5743 commit bc3707b
Show file tree
Hide file tree
Showing 13 changed files with 194 additions and 61 deletions.
6 changes: 3 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,18 @@ The project name is inspired by a great animation named "Liz and the Blue bird".

## Installation

### Download from [Release](https://github.com/philia897/liz-shortcut-helper/releases)

Download the tar.gz package, and run the install.sh to install and auto configure everything.

```
tar -xzf [package_name.tar.gz]
cd [package_name]
./install.sh
```

### Building from source

Fist please make sure `rustc` and `cargo` already installed for building this project. For Arch user, you can use `sudo pacman -Sy rust` to install both.
Expand All @@ -37,6 +49,8 @@ rm -rf release/ release.tar.gz

```

> If you have problems with ydotool (can not start the service, socket file permission wrong, etc): [read this](./doc/ydotool/README.md)
## How to use

```bash
Expand Down
2 changes: 1 addition & 1 deletion andthe/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "andthe"
version = "0.1.0"
version = "0.1.1"
edition = "2021"
authors = ["Felix Wang <wangzekun.felix@gmail.com>"]
description = "Defines the communication protocol between Liz and Bluebird for liz-shortcut-helper"
Expand Down
2 changes: 1 addition & 1 deletion bluebird/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "bluebird"
version = "0.1.0"
version = "0.1.1"
edition = "2021"
authors = ["Felix Wang <wangzekun.felix@gmail.com>"]
description = "The daemon hearing, executing and responding to the commends from Liz for liz-shortcut-helper"
Expand Down
2 changes: 1 addition & 1 deletion data/music_sheet.lock
Original file line number Diff line number Diff line change
@@ -1 +1 @@
[{"hit_number":7,"comment":"Clear the command prompt typed","keycode":"29.1 22.1 22.0 29.0","formatted":"<b>Clear command prompt</b> | Terminal | ctrl+u"},{"hit_number":6,"comment":"","keycode":"126.1 109.1 109.0 126.0","formatted":"<b>Minimize Window</b> | KWin | meta+pagedown"},{"hit_number":5,"comment":"Welcom message","keycode":"<str>+ Hello World!<str>","formatted":"<b>Hello world</b> | Welcome | (str)+ Hello World!"},{"hit_number":2,"comment":"Test to run shortcut 'ctrl+shift+c', the copy command in Zsh","keycode":"29.1 42.1 46.1 46.0 42.0 29.0","formatted":"<b>Test: ctrl+shift+c</b> | Example | ctrl+shift+c"},{"hit_number":2,"comment":"Test to run shortcut 'esc :set nu', set number in vim/nvim","keycode":"1.1 1.0 <str>+ :set<str> 57.1 57.0 <str>+ nu<str>","formatted":"<b>Test: esc :set nu</b> | Example | esc :set space nu"},{"hit_number":2,"comment":"Welcom message","keycode":"<str>+ liz and the blue bird<str>","formatted":"<b>Welcome</b> | Welcome | (str)+ liz and the blue bird"},{"hit_number":1,"comment":"","keycode":"126.1 104.1 104.0 126.0","formatted":"<b>Maximize Window</b> | KWin | meta+pageup"},{"hit_number":1,"comment":"Test to run shortcut 'esc :set nu', using (str) to type string instead","keycode":"1.1 1.0 <str>+ :set nu<str>","formatted":"<b>Test: esc :set nu (alternative)</b> | Example | esc (str)+ :set nu"},{"hit_number":1,"comment":"Test to run shortcut 'esc :set nu enter', using (str) to type string instead","keycode":"1.1 1.0 <str>+ :set nu<str> 28.1 28.0","formatted":"<b>Test: esc :set nu enter (alternative)</b> | Example | esc (str)+ :set nu (str) enter"},{"hit_number":1,"comment":"Test to run shortcut 'meta+pageup', maximize window in KDE or maybe other desktop","keycode":"126.1 104.1 104.0 126.0","formatted":"<b>Test: meta+pageup</b> | Example | meta+pageup"},{"hit_number":1,"comment":"Go to begin of command prompt","keycode":"29.1 30.1 30.0 29.0","formatted":"<b>To command begin</b> | Terminal | ctrl+a"},{"hit_number":1,"comment":"Go to end of command prompt","keycode":"29.1 18.1 18.0 29.0","formatted":"<b>To command end</b> | Terminal | ctrl+e"},{"hit_number":0,"comment":"","keycode":"56.1 62.1 62.0 56.0","formatted":"<b>Close Window</b> | KWin | alt+f4"},{"hit_number":0,"comment":"Copy the current line","keycode":"1.1 1.0 <str>+ yy<str>","formatted":"<b>Copy Line</b> | Nvim | esc yy"},{"hit_number":0,"comment":"Copy the selected text to Nvim register 'a'","keycode":"<str>+ \"<str> <str>+ ay<str>","formatted":"<b>Copy the selection to Nvim register</b> | Nvim | \" ay"},{"hit_number":0,"comment":"Copy the selected text to the system clipboard","keycode":"<str>+ \"<str> <str>+ +<str> 21.1 21.0","formatted":"<b>Copy the selection to system clipboard</b> | Nvim | \" + y"},{"hit_number":0,"comment":"Cut the current line","keycode":"1.1 1.0 <str>+ dd<str>","formatted":"<b>Cut Line</b> | Nvim | esc dd"},{"hit_number":0,"comment":"Move the cursor to the beginning of the page (scroll up)","keycode":"1.1 1.0 <str>+ gg<str>","formatted":"<b>Go to the file begin</b> | Nvim | esc gg"},{"hit_number":0,"comment":"Move the cursor to the end of the page (scroll down)","keycode":"1.1 1.0 34.1 34.0","formatted":"<b>Go to the file end</b> | Nvim | esc G"},{"hit_number":0,"comment":"Move the cursor to the beginning of the current line","keycode":"1.1 1.0 11.1 11.0","formatted":"<b>Go to the line begin</b> | Nvim | esc 0"},{"hit_number":0,"comment":"Move the cursor to the end of the current line","keycode":"1.1 1.0 <str>+ $<str>","formatted":"<b>Go to the line end</b> | Nvim | esc $"},{"hit_number":0,"comment":"Paste the content from Nvim register 'a'","keycode":"1.1 1.0 <str>+ \"<str> <str>+ ap<str>","formatted":"<b>Paste the Nvim register</b> | Nvim | esc \" ap"},{"hit_number":0,"comment":"Paste the content from the system clipboard","keycode":"1.1 1.0 <str>+ \"<str> <str>+ +<str> 25.1 25.0","formatted":"<b>Paste the system clipboard</b> | Nvim | esc \" + p"},{"hit_number":0,"comment":"Paste after the cursor","keycode":"1.1 1.0 25.1 25.0","formatted":"<b>Paste</b> | Nvim | esc p"},{"hit_number":0,"comment":"Quit Nvim without saving changes","keycode":"1.1 1.0 <str>+ :q!<str> 28.1 28.0","formatted":"<b>Quit Without Saving</b> | Nvim | esc :q! enter"},{"hit_number":0,"comment":"Quit Nvim","keycode":"1.1 1.0 <str>+ :q<str> 28.1 28.0","formatted":"<b>Quit</b> | Nvim | esc :q enter"},{"hit_number":0,"comment":"Redo the last undone change","keycode":"1.1 1.0 29.1 19.1 19.0 29.0","formatted":"<b>Redo</b> | Nvim | esc ctrl+r"},{"hit_number":0,"comment":"Replace 'old' with 'new' throughout the file","keycode":"1.1 1.0 <str>+ :%s/old/new/g<str> 28.1 28.0","formatted":"<b>Replace in File</b> | Nvim | esc :%s/old/new/g enter"},{"hit_number":0,"comment":"Save the current file","keycode":"1.1 1.0 <str>+ :w<str> 28.1 28.0","formatted":"<b>Save File</b> | Nvim | esc :w enter"},{"hit_number":0,"comment":"Save the current file and quit Nvim","keycode":"1.1 1.0 <str>+ :wq<str> 28.1 28.0","formatted":"<b>Save and Quit</b> | Nvim | esc :wq enter"},{"hit_number":0,"comment":"Search for 'old' and replace with 'new' throughout the file","keycode":"1.1 1.0 <str>+ :%s/old/new/g<str>","formatted":"<b>Search and replace all</b> | Nvim | esc :%s/old/new/g"},{"hit_number":0,"comment":"Search for 'old' and replace with 'new' (confirm each replacement)","keycode":"1.1 1.0 <str>+ :s/old/new/gc<str>","formatted":"<b>Search and replace one</b> | Nvim | esc :s/old/new/gc"},{"hit_number":0,"comment":"Search case-insensitive within the file","keycode":"1.1 1.0 <str>+ /\\\\C<str>","formatted":"<b>Search case-insensitive</b> | Nvim | esc /\\\\C"},{"hit_number":0,"comment":"Search case-sensitive within the file","keycode":"1.1 1.0 <str>+ /\\\\c<str> 105.1 105.0 105.1 105.0","formatted":"<b>Search case-sensitive</b> | Nvim | esc /\\\\c left left"},{"hit_number":0,"comment":"Next search result of history","keycode":"29.1 49.1 49.0 29.0","formatted":"<b>Search command history (next)</b> | Terminal | ctrl+n"},{"hit_number":0,"comment":"Previous search result of history","keycode":"29.1 25.1 25.0 29.0","formatted":"<b>Search command history (previous)</b> | Terminal | ctrl+p"},{"hit_number":0,"comment":"Search command history in the terminal","keycode":"29.1 19.1 19.0 29.0","formatted":"<b>Search command history</b> | Terminal | ctrl+r"},{"hit_number":0,"comment":"Search within the file","keycode":"1.1 1.0 53.1 53.0","formatted":"<b>Search in File</b> | Nvim | esc /"},{"hit_number":0,"comment":"Test to run shortcut 'esc :set nu enter', set number in vim/nvim","keycode":"1.1 1.0 <str>+ :set<str> 57.1 57.0 <str>+ nu<str> 57.1 57.0 28.1 28.0","formatted":"<b>Test: esc :set nu space enter</b> | Example | esc :set space nu space enter"},{"hit_number":0,"comment":"Undo the last change","keycode":"1.1 1.0 22.1 22.0","formatted":"<b>Undo</b> | Nvim | esc u"}]
[{"hit_number":8,"comment":"Clear the command prompt typed","keycode":"29.1 22.1 22.0 29.0","formatted":"<b>Clear command prompt</b> | Terminal | ctrl+u"},{"hit_number":6,"comment":"Welcom message","keycode":"<str>+ Hello World!<str>","formatted":"<b>Hello world</b> | Welcome | (str)+ Hello World!"},{"hit_number":6,"comment":"","keycode":"126.1 109.1 109.0 126.0","formatted":"<b>Minimize Window</b> | KWin | meta+pagedown"},{"hit_number":2,"comment":"Test to run shortcut 'ctrl+shift+c', the copy command in Zsh","keycode":"29.1 42.1 46.1 46.0 42.0 29.0","formatted":"<b>Test: ctrl+shift+c</b> | Example | ctrl+shift+c"},{"hit_number":2,"comment":"Test to run shortcut 'esc :set nu', set number in vim/nvim","keycode":"1.1 1.0 <str>+ :set<str> 57.1 57.0 <str>+ nu<str>","formatted":"<b>Test: esc :set nu</b> | Example | esc :set space nu"},{"hit_number":2,"comment":"Welcom message","keycode":"<str>+ liz and the blue bird<str>","formatted":"<b>Welcome</b> | Welcome | (str)+ liz and the blue bird"},{"hit_number":1,"comment":"","keycode":"126.1 104.1 104.0 126.0","formatted":"<b>Maximize Window</b> | KWin | meta+pageup"},{"hit_number":1,"comment":"Test to run shortcut 'esc :set nu', using (str) to type string instead","keycode":"1.1 1.0 <str>+ :set nu<str>","formatted":"<b>Test: esc :set nu (alternative)</b> | Example | esc (str)+ :set nu"},{"hit_number":1,"comment":"Test to run shortcut 'esc :set nu enter', using (str) to type string instead","keycode":"1.1 1.0 <str>+ :set nu<str> 28.1 28.0","formatted":"<b>Test: esc :set nu enter (alternative)</b> | Example | esc (str)+ :set nu (str) enter"},{"hit_number":1,"comment":"Test to run shortcut 'meta+pageup', maximize window in KDE or maybe other desktop","keycode":"126.1 104.1 104.0 126.0","formatted":"<b>Test: meta+pageup</b> | Example | meta+pageup"},{"hit_number":1,"comment":"Go to begin of command prompt","keycode":"29.1 30.1 30.0 29.0","formatted":"<b>To command begin</b> | Terminal | ctrl+a"},{"hit_number":1,"comment":"Go to end of command prompt","keycode":"29.1 18.1 18.0 29.0","formatted":"<b>To command end</b> | Terminal | ctrl+e"},{"hit_number":0,"comment":"","keycode":"56.1 62.1 62.0 56.0","formatted":"<b>Close Window</b> | KWin | alt+f4"},{"hit_number":0,"comment":"Copy the current line","keycode":"1.1 1.0 <str>+ yy<str>","formatted":"<b>Copy Line</b> | Nvim | esc yy"},{"hit_number":0,"comment":"Copy the selected text to Nvim register 'a'","keycode":"<str>+ \"<str> <str>+ ay<str>","formatted":"<b>Copy the selection to Nvim register</b> | Nvim | \" ay"},{"hit_number":0,"comment":"Copy the selected text to the system clipboard","keycode":"<str>+ \"<str> <str>+ +<str> 21.1 21.0","formatted":"<b>Copy the selection to system clipboard</b> | Nvim | \" + y"},{"hit_number":0,"comment":"Cut the current line","keycode":"1.1 1.0 <str>+ dd<str>","formatted":"<b>Cut Line</b> | Nvim | esc dd"},{"hit_number":0,"comment":"Move the cursor to the beginning of the page (scroll up)","keycode":"1.1 1.0 <str>+ gg<str>","formatted":"<b>Go to the file begin</b> | Nvim | esc gg"},{"hit_number":0,"comment":"Move the cursor to the end of the page (scroll down)","keycode":"1.1 1.0 34.1 34.0","formatted":"<b>Go to the file end</b> | Nvim | esc G"},{"hit_number":0,"comment":"Move the cursor to the beginning of the current line","keycode":"1.1 1.0 11.1 11.0","formatted":"<b>Go to the line begin</b> | Nvim | esc 0"},{"hit_number":0,"comment":"Move the cursor to the end of the current line","keycode":"1.1 1.0 <str>+ $<str>","formatted":"<b>Go to the line end</b> | Nvim | esc $"},{"hit_number":0,"comment":"Paste the content from Nvim register 'a'","keycode":"1.1 1.0 <str>+ \"<str> <str>+ ap<str>","formatted":"<b>Paste the Nvim register</b> | Nvim | esc \" ap"},{"hit_number":0,"comment":"Paste the content from the system clipboard","keycode":"1.1 1.0 <str>+ \"<str> <str>+ +<str> 25.1 25.0","formatted":"<b>Paste the system clipboard</b> | Nvim | esc \" + p"},{"hit_number":0,"comment":"Paste after the cursor","keycode":"1.1 1.0 25.1 25.0","formatted":"<b>Paste</b> | Nvim | esc p"},{"hit_number":0,"comment":"Quit Nvim without saving changes","keycode":"1.1 1.0 <str>+ :q!<str> 28.1 28.0","formatted":"<b>Quit Without Saving</b> | Nvim | esc :q! enter"},{"hit_number":0,"comment":"Quit Nvim","keycode":"1.1 1.0 <str>+ :q<str> 28.1 28.0","formatted":"<b>Quit</b> | Nvim | esc :q enter"},{"hit_number":0,"comment":"Redo the last undone change","keycode":"1.1 1.0 29.1 19.1 19.0 29.0","formatted":"<b>Redo</b> | Nvim | esc ctrl+r"},{"hit_number":0,"comment":"Replace 'old' with 'new' throughout the file","keycode":"1.1 1.0 <str>+ :%s/old/new/g<str> 28.1 28.0","formatted":"<b>Replace in File</b> | Nvim | esc :%s/old/new/g enter"},{"hit_number":0,"comment":"Save the current file","keycode":"1.1 1.0 <str>+ :w<str> 28.1 28.0","formatted":"<b>Save File</b> | Nvim | esc :w enter"},{"hit_number":0,"comment":"Save the current file and quit Nvim","keycode":"1.1 1.0 <str>+ :wq<str> 28.1 28.0","formatted":"<b>Save and Quit</b> | Nvim | esc :wq enter"},{"hit_number":0,"comment":"Search for 'old' and replace with 'new' throughout the file","keycode":"1.1 1.0 <str>+ :%s/old/new/g<str>","formatted":"<b>Search and replace all</b> | Nvim | esc :%s/old/new/g"},{"hit_number":0,"comment":"Search for 'old' and replace with 'new' (confirm each replacement)","keycode":"1.1 1.0 <str>+ :s/old/new/gc<str>","formatted":"<b>Search and replace one</b> | Nvim | esc :s/old/new/gc"},{"hit_number":0,"comment":"Search case-insensitive within the file","keycode":"1.1 1.0 <str>+ /\\\\C<str>","formatted":"<b>Search case-insensitive</b> | Nvim | esc /\\\\C"},{"hit_number":0,"comment":"Search case-sensitive within the file","keycode":"1.1 1.0 <str>+ /\\\\c<str> 105.1 105.0 105.1 105.0","formatted":"<b>Search case-sensitive</b> | Nvim | esc /\\\\c left left"},{"hit_number":0,"comment":"Next search result of history","keycode":"29.1 49.1 49.0 29.0","formatted":"<b>Search command history (next)</b> | Terminal | ctrl+n"},{"hit_number":0,"comment":"Previous search result of history","keycode":"29.1 25.1 25.0 29.0","formatted":"<b>Search command history (previous)</b> | Terminal | ctrl+p"},{"hit_number":0,"comment":"Search command history in the terminal","keycode":"29.1 19.1 19.0 29.0","formatted":"<b>Search command history</b> | Terminal | ctrl+r"},{"hit_number":0,"comment":"Search within the file","keycode":"1.1 1.0 53.1 53.0","formatted":"<b>Search in File</b> | Nvim | esc /"},{"hit_number":0,"comment":"Test to run shortcut 'esc :set nu enter', set number in vim/nvim","keycode":"1.1 1.0 <str>+ :set<str> 57.1 57.0 <str>+ nu<str> 57.1 57.0 28.1 28.0","formatted":"<b>Test: esc :set nu space enter</b> | Example | esc :set space nu space enter"},{"hit_number":0,"comment":"Undo the last change","keycode":"1.1 1.0 22.1 22.0","formatted":"<b>Undo</b> | Nvim | esc u"}]
File renamed without changes.
2 changes: 1 addition & 1 deletion liz/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "liz"
version = "0.1.0"
version = "0.1.1"
edition = "2021"
authors = ["Felix Wang <wangzekun.felix@gmail.com>"]
description = "The client to send commands to bluebird for liz-shortcut-helper"
Expand Down
42 changes: 39 additions & 3 deletions scripts/copy_to_config_liz.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,49 @@ set -e
# Define the target directory
TARGET_DIR="$HOME/.config/liz"

# Check if the target directory exists, create it if not
if [ ! -d "$TARGET_DIR" ]; then
# Check if the target directory exists
if [ -d "$TARGET_DIR" ]; then
echo "Directory $TARGET_DIR already exists."
read -p "Do you want to overwrite it? (y/N): " choice
choice=${choice:-N} # Default to 'N' if no input is provided
case "$choice" in
[yY][eE][sS]|[yY])
echo "Overwriting $TARGET_DIR..."
rm -rf "$TARGET_DIR"
mkdir -p "$TARGET_DIR"
;;
*)
echo "Exiting without making changes."
return 0
;;
esac
else
echo "Directory $TARGET_DIR does not exist. Creating it..."
mkdir -p "$TARGET_DIR"
fi

source generate_default_rhythm.sh

# Get the current username
USER=$(whoami)

# Define the paths with the current user
LIZ_PATH="/home/$USER/.config/liz/"
MUSIC_SHEET_PATH="/home/$USER/Workroom/liz-shortcut-helper/data/music_sheet.lock"
USER_SHEETS_PATH="/home/$USER/Workroom/liz-shortcut-helper/data/sheets"
KEYMAP_PATH="/home/$USER/.config/liz/keymap.json"
YDOTTOOL_SOCKET_PATH="/tmp/.ydotool_socket"

# Create the rhythm.toml file with the paths
cat <<EOL > ./data/rhythm.toml
liz_path = "$LIZ_PATH"
music_sheet_path = "$MUSIC_SHEET_PATH"
user_sheets_path = "$USER_SHEETS_PATH"
keymap_path = "$KEYMAP_PATH"
ydotool_socket_path = "$YDOTTOOL_SOCKET_PATH"
EOL

echo "rhythm.toml has been generated with paths for user '$USER'."


# Copy files from ./data/* to ~/.config/liz
echo "Copying files from ./data/* to $TARGET_DIR..."
Expand Down
22 changes: 0 additions & 22 deletions scripts/generate_default_rhythm.sh

This file was deleted.

26 changes: 16 additions & 10 deletions scripts/install.sh
Original file line number Diff line number Diff line change
@@ -1,17 +1,23 @@
#!/bin/bash
set -e

echo "Move binaries to /usr/local/bin"
sudo cp liz /usr/local/bin/
sudo cp bluebird /usr/local/bin/
# Copy the data/* to the default place where is
# /home/yourname/.config/liz/
# If it already exists, feel free to comment and skip this
source copy_to_config_liz.sh || { echo "Install Failed"; exit 1; }

echo "Make binaries executable"
sudo chmod +x /usr/local/bin/liz
sudo chmod +x /usr/local/bin/bluebird
# Intall ydotool and rofi, if you already installed them
# or you want to install by yourself, comment this
source install_dependencies.sh || { echo "Install Failed"; exit 1; }

source copy_to_config_liz.sh
source install_dependencies.sh
source setup_ydotoold_service.sh
source setup_bluebird_service.sh /usr/local/bin/bluebird
# Setup the ydotool deamon service, if youw want to do this
# manually, skip this. Or you can check this to see what it
# does and make sure it is safe in your system.
source setup_ydotoold_service.sh || { echo "Install Failed"; exit 1; }

# Setup the bluebird service, and enable it to automatically
# start on startup. It is mandatory, and should NOT be commented
# Or the bluebird and liz will not be upgraded.
source setup_bluebird_service.sh || { echo "Install Failed"; exit 1; }

echo "Install complete!"
Loading

0 comments on commit bc3707b

Please sign in to comment.