Skip to content

Commit

Permalink
Initial upload of script and first real README
Browse files Browse the repository at this point in the history
  • Loading branch information
TheLustriVA committed May 5, 2023
1 parent 88c945a commit 1cfd43d
Show file tree
Hide file tree
Showing 2 changed files with 162 additions and 0 deletions.
96 changes: 96 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,98 @@
# DTESET-for-AppImages

An interactive shell script that writes a Desktop Entry for AppImage files.

## Usage

I'm aware that some of these instructions are not absolute best-practice, but I'm trying to make this as accessible as possible.

### Without Repository

Navigate to the directory where the AppImage file is located and grab the script using wget:

```bash
wget https://raw.githubusercontent.com/thelustriva/DTESET-for-AppImages/main/dteset.sh
```

Make the script executable:

```bash
chmod +x dteset
```

Run the script:

```bash
./dteset SomeProgram.AppImage
```

### With Repository: User-only

Clone the repository:

```bash
git clone git@github.com:TheLustriVA/DTESET-for-AppImages.git
cd DTESET-for-AppImages
```

To make the `dteset` script available for use anywhere in the filesystem for your user, you can place it in a directory that is part of your user's `PATH` environment variable.

Create a `bin` directory in your home directory, if it doesn't already exist:

```bash
mkdir -p ~/bin
```

Move the `dteset` script to the `~/bin` directory:

```bash
mv dteset ~/bin/
```

Ensure that the `~/bin` directory is included in your `PATH`. Open (or create) the `~/.bashrc` file in a text editor:

```bash
nano ~/.bashrc
```

Add the following lines to the end of the file, if they don't already exist:

```bash
if [ -d "$HOME/bin" ] ; then
PATH="$HOME/bin:$PATH"
fi
```

Save and exit the file.

Apply the changes by running:

```bash
source ~/.bashrc
```

Now, you should be able to use the `dteset` command from anywhere in the filesystem:

```bash
dteset SomeProgram.AppImage
```

Remember that this will only work for your user. If you want to make the script available to other users as well, you can place it in a system-wide directory like `/usr/local/bin`. However, this will require administrator privileges.

### With Repository: All Users

Clone the repository as shown in the instructions above.

Move the dteset script to a suitable location, such as /opt. This step is optional, but it helps to keep the script organized and accessible:

```bash
sudo mv dteset /opt/
```

Create a symlink to the dteset script in /usr/local/bin:

```bash
sudo ln -s /opt/dteset /usr/local/bin/dteset
```

Now, the dteset script should be available system-wide, and all users can use the command from anywhere in the filesystem. Since the script is placed in a system-wide location, anyone using it will need to have the right permissions to execute the script.
66 changes: 66 additions & 0 deletions dteset.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
#!/bin/bash

if [ -z "$1" ]; then
echo "Usage: dteset <AppImage>"
exit 1
fi

APPIMAGE="$1"

echo "**********************************"
echo "Desktop Entry Setter"
echo "**********************************"

read -p "Path to the AppImage [default: $(pwd)/${APPIMAGE}]: " path
path=${path:-$(pwd)/${APPIMAGE}}

echo "Type:"
echo "1) Application"
echo "2) Link"
echo "3) Directory"
read -p "Choose the type [default: 1]: " type_choice

case "$type_choice" in
2) type="Link" ;;
3) type="Directory" ;;
*) type="Application" ;;
esac

read -p "Name [default: ${APPIMAGE%.AppImage}]: " name
name=${name:-${APPIMAGE%.AppImage}}

read -p "Exec [default: ${path}]: " exec
exec=${exec:-${path}}

read -p "Icon [default: utilities-terminal]: " icon
icon=${icon:-utilities-terminal}

read -p "Categories (semicolon-separated) [default: Utility;Application;]: " categories
categories=${categories:-Utility;Application;}

echo ""
echo "--> The details you entered will result in the following desktop entry:"
echo "[Desktop Entry]"
echo "Type=${type}"
echo "Name=${name}"
echo "Exec=${exec}"
echo "Icon=${icon}"
echo "Categories=${categories}"
echo ""

read -p "Is this correct? Y/n: " confirmation

if [[ "${confirmation,,}" != "n" ]]; then
mkdir -p ~/.local/share/applications
echo "[Desktop Entry]" > ~/.local/share/applications/${name}.desktop
echo "Type=${type}" >> ~/.local/share/applications/${name}.desktop
echo "Name=${name}" >> ~/.local/share/applications/${name}.desktop
echo "Exec=${exec}" >> ~/.local/share/applications/${name}.desktop
echo "Icon=${icon}" >> ~/.local/share/applications/${name}.desktop
echo "Categories=${categories}" >> ~/.local/share/applications/${name}.desktop
echo "Desktop entry set."
echo "**********************************"
else
echo "Desktop entry not set."
echo "**********************************"
fi

0 comments on commit 1cfd43d

Please sign in to comment.