Skip to content

Commit

Permalink
[MED] ALPHA 2.2
Browse files Browse the repository at this point in the history
  • Loading branch information
nots1dd committed Jan 19, 2025
1 parent ef777a1 commit 1bcb7ac
Show file tree
Hide file tree
Showing 15 changed files with 427 additions and 163 deletions.
33 changes: 33 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -696,3 +696,36 @@ Small commit with some issues + cmd line args setup
- Centering of the image_view

---

## [ALPHA 2.2] --- 19-01-2025

### Added
- `assets/completions/inLimbo-completions.fish` and `assets/inLimbo.desktop`

### Changed
- Refactored the arg-handler and cmd-line-args headers

- Completions for `BASH`, `ZSH` and `FISH` shells work with testing

- inLimbo.desktop setup works (with rofi, not ags for some reason)

- `init.sh` now sets up the preferred shell for command line args completion

- Added option to build globally

### Fixed
- Completions for BASH and ZSH

- Removed unnecessary header that broke CodeQL CI

### Removed
**NIL**

Small commit with some nice touch ups for user interaction with the binary

### Known Issues to fix in immediate commits
- Runtime errors with respect to `PlayCurrentSong()` that may be due to detaching the audio thread (BIG)

- Centering of the image_view (NOT THAT BIG)

---
20 changes: 20 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ add_library(tiv
${CMAKE_CURRENT_SOURCE_DIR}/src/ui/components/libs/tiv_lib.cpp
)

# Option to select between local or global build
option(BUILD_GLOBAL "Build globally and install" OFF)

# --- Fetch FTXUI --------------------------------------------------------------
include(FetchContent)

Expand Down Expand Up @@ -108,6 +111,23 @@ else()
target_link_libraries(${EXECUTABLE_NAME})
endif()

# --- Handle Global Build ---------------------------------------------------------
if(BUILD_GLOBAL)
set(CMAKE_INSTALL_PREFIX "/usr/")
message(STATUS "Starting GLOBAL_BUILD for inLimbo...")

install(TARGETS ${EXECUTABLE_NAME} DESTINATION bin)

install(FILES assets/inLimbo.desktop DESTINATION share/applications)
install(FILES assets/logo/inLimbo.png DESTINATION share/icons/hicolor/256x256/apps)

else()
# Local build (build in ./build directory)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/build")

message(STATUS "Building locally, binaries will be located in ./build/")
endif()

# Ensure that pkg-config is available
find_package(PkgConfig REQUIRED)

Expand Down
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,15 @@ cmake --build build/
./build/inLimbo
```

To build inLimbo **GLOBALLY**:

```bash
cmake -S . -B build -DBUILD_GLOBAL=ON
cmake --build build/
cd build
sudo make install # will put the binary in /usr/bin and respective inLimbo.desktop and logo in /usr/share
```

To build its web-assembly, you will need [emscripten](https://github.com/emscripten-core/emscripten)

> [!IMPORTANT]
Expand Down
1 change: 1 addition & 0 deletions VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2.2 - ALPHA
17 changes: 15 additions & 2 deletions assets/completions/inLimbo-completions.bash
Original file line number Diff line number Diff line change
@@ -1,15 +1,28 @@
#!/bin/bash

_inLimbo_completions() {
local cur prev opts
local cur prev opts descriptions
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
opts="--help --version --clear-cache --show-config-file --show-log-dir --show-dbus-name"
descriptions=(
"--help Show help information"
"--version Display the version of inLimbo"
"--clear-cache Clear cached data"
"--show-config-file Show the configuration file path"
"--show-log-dir Show the log directory path"
"--show-dbus-name Show the DBus service name"
)

# Provide completion for options
if [[ ${cur} == -* ]]; then
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
COMPREPLY=()
for opt in ${opts}; do
if [[ ${opt} == ${cur}* ]]; then
COMPREPLY+=("${opt}")
fi
done
return 0
fi
}
Expand Down
20 changes: 20 additions & 0 deletions assets/completions/inLimbo-completions.fish
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
function _inLimbo_completions
set -l cur (commandline -ct)
set -l opts \
"--help" "Show help information" \
"--version" "Display the version of inLimbo" \
"--clear-cache" "Clear cached data" \
"--show-config-file" "Show the configuration file path" \
"--show-log-dir" "Show the log directory path" \
"--show-dbus-name" "Show the DBus service name"
for i in (seq 1 2 (count $opts))
set -l opt (string trim -- $opts[$i])
set -l desc $opts[(math $i + 1)]
if test -z "$cur"
echo -e "$opt\t$desc\n"
else if string match -q -- "$cur*" $opt
echo -e "$opt\t$desc\n"
end
end
end
complete -f -c inLimbo -a "(_inLimbo_completions)"
37 changes: 11 additions & 26 deletions assets/completions/inLimbo-completions.zsh
Original file line number Diff line number Diff line change
@@ -1,29 +1,14 @@
# inLimbo-completion.zsh
# A very primitive and early conf for inLimbo completions for zsh

_inLimbo_completions() {
local cur prev opts

# Get the current word being typed
cur="${words[$CURRENT]}"
prev="${words[$CURRENT-1]}"

# List of options for the music player
opts="--play --pause --stop --next --prev --shuffle --repeat --volume --help"

# If the current word starts with a dash (option), complete the options
if [[ "$cur" == --* ]]; then
COMPREPLY=($(compgen -W "$opts" -- "$cur"))
return 0
fi

# If the previous word was an option that expects a file path, suggest file paths
if [[ "$prev" == "--play" || "$prev" == "--next" || "$prev" == "--prev" ]]; then
COMPREPLY=($(compgen -f -- "$cur"))
return 0
fi
local -a opts
opts=(
"--help:Show help information"
"--version:Display the version of inLimbo"
"--clear-cache:Clear cached data"
"--show-config-file:Show the configuration file path"
"--show-log-dir:Show the log directory path"
"--show-dbus-name:Show the DBus service name"
)
_describe -t options "inLimbo options" opts
}

# Register the completion for inLimbo using complete
complete -F _inLimbo_completions inLimbo

compdef _inLimbo_completions inLimbo
9 changes: 9 additions & 0 deletions assets/inLimbo.desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[Desktop Entry]
Name=inLimbo
GenericName=Music Player
Comment=Music Player that keeps you in Limbo.
Exec=/usr/bin/inLimbo
Terminal=true
Type=Application
Categories=Audio;Music;Player;ConsoleOnly;
Icon=inLimbo-Logo
Binary file added assets/logo/inLimbo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
108 changes: 106 additions & 2 deletions init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ CYAN="\033[36m"
PINK="\033[95m"
RESET="\033[0m"

declare -A COMPLETION_FILES=(
["bash"]="assets/completions/inLimbo-completions.bash"
["zsh"]="assets/completions/inLimbo-completions.zsh"
["fish"]="assets/completions/inLimbo-completions.fish"
)

# Some URL definitions
TOML_PARSER_URL="https://raw.githubusercontent.com/marzer/tomlplusplus/master/toml.hpp"
MINIAUDIO_URL="https://raw.githubusercontent.com/mackron/miniaudio/master/miniaudio.h"
Expand All @@ -26,7 +32,7 @@ show_msg() {
local url=$2
local target_dir=$3
local filename=$(basename "$url")

print_delim
echo -e "${YELLOW}${message}${RESET}"
echo -e "${CYAN}Downloading to ${target_dir}...${RESET}"
Expand All @@ -36,7 +42,7 @@ show_msg() {

# Download the file to the specified directory
if curl -o "${target_dir}/${filename}" "$url"; then
echo -e "${GREEN}Successfully downloaded ${filename} to ${target_dir}.${RESET}"
echo -e "${GREEN}Successfully downloaded ${filename} to ${target_dir}.${RESET}"
else
echo -e "${RED}Failed to download ${filename}.${RESET}"
exit 1
Expand All @@ -45,9 +51,107 @@ show_msg() {
print_delim
}

setup_shell_completions() {
print_delim
echo -e "${CYAN}Shell Completion Setup${RESET}"
echo -e "${YELLOW}Which shells would you like to set up completions for?${RESET}"
echo
echo -e "${GREEN}Available options:${RESET}"
echo -e "1) ${BLUE}bash${RESET}"
echo -e "2) ${BLUE}zsh${RESET}"
echo -e "3) ${BLUE}fish${RESET}"
echo -e "4) ${PURPLE}all${RESET}"
echo -e "0) ${RED}none${RESET}"
echo
echo -e "${YELLOW}Enter your choices (space-separated numbers, e.g., '1 2' or '4' for all):${RESET} "
read -r choices

# Convert "4" to "1 2 3" (all options)
if [[ $choices == "4" ]]; then
choices="1 2 3"
fi

# Early exit if none selected
if [[ $choices == "0" ]]; then
echo -e "${YELLOW}No shell completions will be set up.${RESET}"
return
fi

# Process each selected shell
for choice in $choices; do
case $choice in
1)
setup_bash_completion
;;
2)
setup_zsh_completion
;;
3)
setup_fish_completion
;;
esac
done
}

setup_bash_completion() {
local bashrc="$HOME/.bashrc"
local completion_path="$(pwd)/${COMPLETION_FILES[bash]}"

echo -e "${BLUE}Setting up Bash completion...${RESET}"
if [[ -f "$completion_path" ]]; then
if ! grep -q "$completion_path" "$bashrc"; then
echo "source $completion_path" >> "$bashrc"
echo -e "${GREEN}✓ Bash completion added to $bashrc${RESET}"
else
echo -e "${YELLOW}! Bash completion already configured${RESET}"
fi
else
echo -e "${RED}✗ Bash completion file not found at $completion_path${RESET}"
fi
}

setup_zsh_completion() {
local zshrc="$HOME/.zshrc"
local completion_path="$(pwd)/${COMPLETION_FILES[zsh]}"

echo -e "${BLUE}Setting up Zsh completion...${RESET}"
if [[ -f "$completion_path" ]]; then
if ! grep -q "$completion_path" "$zshrc"; then
echo "source $completion_path" >> "$zshrc"
echo -e "${GREEN}✓ Zsh completion added to $zshrc${RESET}"
else
echo -e "${YELLOW}! Zsh completion already configured${RESET}"
fi
else
echo -e "${RED}✗ Zsh completion file not found at $completion_path${RESET}"
fi
}

setup_fish_completion() {
local fish_dir="$HOME/.config/fish/completions"
local completion_path="$(pwd)/${COMPLETION_FILES[fish]}"
local target_path="$fish_dir/inLimbo.fish"

echo -e "${BLUE}Setting up Fish completion...${RESET}"
if [[ -f "$completion_path" ]]; then
mkdir -p "$fish_dir"
if [[ ! -f "$target_path" ]]; then
cp "$completion_path" "$target_path"
echo "source $target_path" >> "$HOME/.config/fish/config.fish"
echo -e "${GREEN}✓ Fish completion installed to $target_path${RESET}"
else
echo -e "${YELLOW}! Fish completion already installed${RESET}"
fi
else
echo -e "${RED}✗ Fish completion file not found at $completion_path${RESET}"
fi
}

# Example usage
show_msg "1. Download header 'toml.hpp'" $TOML_PARSER_URL "./src/parser/"
show_msg "2. Download header 'miniaudio.h'" $MINIAUDIO_URL "./src/music/"
show_msg "3. Download header 'CImg.h'" $CIMG_URL "./src/ui/components/libs/"

setup_shell_completions

echo -e "${CYAN}------------------ Initialization DONE --------------------${RESET}"
Loading

0 comments on commit 1bcb7ac

Please sign in to comment.