Skip to content

Commit

Permalink
updated scripts and install/uninstall processes, revised LICENSE and …
Browse files Browse the repository at this point in the history
…README
  • Loading branch information
nicolodiamante committed Aug 6, 2024
1 parent 6945461 commit 4bd29a4
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 24 deletions.
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

&#169; 2023 Nicolò Diamante <[email protected]>
&#169; 2024 Nicolò Diamante <[email protected]>

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
Expand Down
28 changes: 14 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
<p align="center">
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://github.com/nicolodiamante/norflow/assets/48920263/d6bb011e-000e-4469-85ae-dd7a53c578e4" draggable="false" ondragstart="return false;" alt="norflow" title="norflow" />
<img src="https://github.com/nicolodiamante/norflow/assets/48920263/6c2493b9-ccf0-45fe-b0b4-a645b488c0ca" draggable="false" ondragstart="return false; "alt="norflow" title="norflow" />
<source media="(prefers-color-scheme: dark)" srcset="https://github.com/user-attachments/assets/22739c01-18eb-463f-ba08-f4dddb9e3ea4" draggable="false" ondragstart="return false;" alt="norflow" title="norflow" />
<img src="https://github.com/user-attachments/assets/b82d0304-3c5d-42c9-bd21-a2311b0415f5" draggable="false" ondragstart="return false; "alt="norflow" title="norflow" />
</picture>
</p>

[Apple shortcuts][apple-shortcuts] is indeed a powerful tool that enables users to simplify their daily tasks and complete them with ease. With just a tap or a voice command, you can perform a wide range of actions, such as sending messages, setting reminders, or playing your favourite music. Additionally, the Shortcuts app allows you to create personalised shortcuts with multiple steps, which can save you significant time and effort.
[Apple Shortcuts][apple-shortcuts] is indeed a powerful tool that enables users to simplify their daily tasks and complete them with ease. With just a tap or a voice command, you can perform a wide range of actions, such as sending messages, setting reminders, or playing your favourite music. Additionally, the Shortcuts app allows you to create personalised shortcuts with multiple steps, which can save you significant time and effort.

However, the app creates an empty folder on your iCloud Drive every time it's opened. While it's possible to store files in this folder, it's often left empty and can become a nuisance. Although deleting the folder manually is harmless, it can be time-consuming and bothersome. This is where a simple utility comes in handy. This utility helps by automatically removing this redundant folder if it's empty, ensuring your iCloud Drive remains clutter-free.
However, the app creates an empty folder on your iCloud Drive every time it's opened. While it's possible to store files in this folder, it's often left empty. Although deleting the folder manually is harmless, it can be time-consuming and bothersome. This is where a simple utility comes in handy. This utility helps by automatically removing this redundant folder if it's empty, ensuring your iCloud Drive remains clutter-free.

<p align="center">
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://github.com/nicolodiamante/norflow/assets/48920263/342c2007-ad34-495d-ade4-aaa73948d41b" draggable="false" ondragstart="return false;" alt="norflow" title="norflow" />
<img src="https://github.com/nicolodiamante/norflow/assets/48920263/651404d0-9a3b-4c69-8430-fe9cc03ef370" draggable="false" ondragstart="return false; "alt="Apple Shortcuts" title="Apple Shortcuts" width="750px" />
<source media="(prefers-color-scheme: dark)" srcset="https://github.com/user-attachments/assets/c2746d4b-110f-4b47-9082-7371f56f18e3" draggable="false" ondragstart="return false;" alt="norflow" title="norflow" />
<img src="https://github.com/user-attachments/assets/fad8c3be-2efc-4ea9-865c-be9366c984be" draggable="false" ondragstart="return false; "alt="Apple Shortcuts" title="Apple Shortcuts" width="750px" />
</picture>
</p>

Expand All @@ -23,7 +23,7 @@ Here are the two methods you can choose from:
**Automatic Download via `curl`**: Simply execute the following command in your terminal to quickly download and seamlessly install the utility:

```shell
sh -c "$(curl -fsSL https://raw.githubusercontent.com/nicolodiamante/norflow/HEAD/bootstrap.sh)"
zsh -c "$(curl -fsSL https://raw.githubusercontent.com/nicolodiamante/norflow/HEAD/bootstrap.zsh)"
```

**Manual Cloning**: For those who prefer a hands-on approach, you can manually clone the repository to your desired location:
Expand All @@ -39,7 +39,7 @@ git clone https://github.com/nicolodiamante/norflow.git ~/norflow
**Directory Navigation & Script Execution**: Navigate to the repository's `utils` directory and execute the installation script:

```shell
source install.sh
source utils/install.zsh
```

**Norflow Configuration**: Running the script will efficiently copy the agent files to `~/Library/LaunchAgents`, ensuring Norflow is seamlessly integrated into your system.
Expand Down Expand Up @@ -74,20 +74,20 @@ Any suggestions or feedback you may have for improvement are welcome. If you enc

<p align="center">
<picture>
<img src="https://github.com/nicolodiamante/norflow/assets/48920263/f3dac045-2175-46d6-91bd-1ece65f7269e" draggable="false" ondragstart="return false;" /></>
<img src="https://github.com/user-attachments/assets/4b9632bd-b010-4b07-8c7c-a5feeefd6fc8" draggable="false" ondragstart="return false;" /></>
</picture>
</p>

<p align="center">
<picture>
<img src="https://github.com/nicolodiamante/norflow/assets/48920263/0047c3eb-f531-45f5-b705-fce0ed75e1de" draggable="false" ondragstart="return false;" alt="Nicol&#242; Diamante" title="Nicol&#242; Diamante" width="17px" />
</picture>
<a href="https://nicolodiamante.com" target="_blank">
<img src="https://github.com/user-attachments/assets/5454fbeb-18c0-426d-8c8e-944977ed01c1" draggable="false" ondragstart="return false;" alt="Nicol&#242; Diamante Portfolio" title="Nicol&#242; Diamante" width="17px" />
</a>
</p>

<p align="center">
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://github.com/nicolodiamante/norflow/assets/48920263/26fa2f3f-9bcc-4c1e-99dc-5c5ca8e3abe7" draggable="false" ondragstart="return false;" alt="MIT License" title="MIT License" />
<img src="https://github.com/nicolodiamante/norflow/assets/48920263/55273eec-42e5-42d0-8efb-8c4f42025f3b" draggable="false" ondragstart="return false; "alt="MIT License" title="MIT License" width="95px" />
<source media="(prefers-color-scheme: dark)" srcset="https://github.com/user-attachments/assets/81a15898-56ae-4a7b-b5a5-49156ccbf32b" draggable="false" ondragstart="return false;" alt="MIT License" title="MIT License" />
<img src="https://github.com/user-attachments/assets/8a89cc7e-ce05-4d47-8176-2c49c248dd48" draggable="false" ondragstart="return false; "alt="MIT License" title="MIT License" width="95px" />
</picture>
</p>

Expand Down
File renamed without changes.
17 changes: 12 additions & 5 deletions script/norflow.zsh
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
#!/bin/zsh

#
# Norflow — Remove the Shortcuts folder if it's empty.
# Norflow — Remove the Shortcuts folder in iCloud Drive.
#

shortcuts=~/Library/Mobile\ Documents/iCloud~is~workflow~my~workflows/Documents
if [[ -z "$(ls -A -I ".WorkflowHiddenFile" $shortcut | head -n 5)" ]]; then
# The folder is empty, then remove it.
rm -rf $shortcuts
SHORTCUTS="${HOME}/Library/Mobile Documents/iCloud~is~workflow~my~workflows/Documents"

# Check if the SHORTCUTS directory exists
if [[ -d "$SHORTCUTS" ]]; then
# Count the number of files excluding .WorkflowHiddenFile
file_count=$(ls -A "${SHORTCUTS}" | grep -v "^\.WorkflowHiddenFile$" | wc -l)

if [[ $file_count -eq 0 ]]; then
# The folder contains only .WorkflowHiddenFile or is empty, then remove it.
rm -rf "${SHORTCUTS}"
fi
fi
19 changes: 16 additions & 3 deletions utils/install.sh → utils/install.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ fi

# Validate macOS version.
SW_VERS=$(sw_vers -buildVersion)
OS_VERS=$(sed -E -e 's/([0-9]{2}).*/\1/' <<<"$SW_VERS")
OS_VERS=$(sed -E -e 's/^([0-9]{2}).*/\1/' <<<"$SW_VERS")
if [[ "$OS_VERS" -lt 21 ]]; then
echo "Error: Norflow requires macOS 12.6.1 Monterey or later."
echo "Error: Norflow requires macOS 12.6.1 Monterey or later." >&2
exit 1
fi

# Defines the PATHs.
# Define the PATHs.
LIB_AGENTS="${HOME}/Library/LaunchAgents"
AGENT_SOURCE="${HOME}/norflow/agent/com.shell.Norflow.plist"
AGENT_TARGET="${LIB_AGENTS}/com.shell.Norflow.plist"
Expand All @@ -40,6 +40,19 @@ else
exit 1
fi

# Check if launchctl is available
if ! command -v launchctl &> /dev/null; then
echo "Error: launchctl command not found." >&2
exit 1
fi

# Unload the agent if it is already loaded.
if launchctl list | grep -q "com.shell.Norflow"; then
if ! launchctl unload "${AGENT_TARGET}"; then
echo "Warning: Failed to unload the existing Norflow agent." >&2
fi
fi

# Load the agent if the source exists.
if [[ -f "$AGENT_SOURCE" ]]; then
if launchctl load "${AGENT_TARGET}"; then
Expand Down
9 changes: 8 additions & 1 deletion utils/uninstall.sh → utils/uninstall.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,20 @@
# Uninstall Norflow.
#

# Defines the PATHs.
# Define the PATHs.
LIB_AGENTS="${HOME}/Library/LaunchAgents"
AGENT="${LIB_AGENTS}/com.shell.Norflow.plist"

# Check if launchctl is available
if ! command -v launchctl &> /dev/null; then
echo "Error: launchctl command not found." >&2
exit 1
fi

# Check if the file exists and is a symlink before attempting to remove.
if [[ -L "${AGENT}" ]]; then
echo "Removing the agent symlink..."

# Unload the agent if it was loaded.
agent_name=$(basename "${AGENT}" .plist)
if launchctl list | grep -q "${agent_name}"; then
Expand Down

0 comments on commit 4bd29a4

Please sign in to comment.