Skip to content

Commit

Permalink
[MAJOR] ALPHA 2.3
Browse files Browse the repository at this point in the history
  • Loading branch information
nots1dd committed Jan 22, 2025
1 parent 1bcb7ac commit dee3e71
Show file tree
Hide file tree
Showing 20 changed files with 344 additions and 47 deletions.
33 changes: 33 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -729,3 +729,36 @@ Small commit with some nice touch ups for user interaction with the binary
- Centering of the image_view (NOT THAT BIG)

---

## [ALPHA 2.3] --- 22-01-2025

### Added
- `src/ui/properties.hpp` -- To parse global properties from config.toml and subsequent changes to `ui_handler`

- `Makefile` for easier building without a hassle, subsequent changes to README

### Changed
- Added new color field (inactive_menu_cursor_bg) and complete integration

- New cmd-line-arg `--update-cache-run` :- Removes cache then reads the directory from config.toml and runs the application (subsequent changes to completions, `cmd-line-args.hpp`, `arg-handler.hpp`)

- Parsing bitrate using TagLib integrated and tested `mp3` and `flac` files

- Audio file MIME types are found and displayed in SongInfoScreen

- UI should not try to PlayNextSong() in Run() function if song_queue is empty.

### Fixed
**NIL**

### Removed
**NIL**

Sizeable commit with new fields, changes and features that bring the app together

### 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)

---
67 changes: 67 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# Makefile for the inLimbo Project

# Variables
BUILD_DIR := build
BUILD_DBG_ASAN_DIR := build-dbg-asan
BUILD_DBG_TSAN_DIR :- build-dbg-tsan
EXECUTABLE := inLimbo
CMAKE := cmake
CMAKE_BUILD_TYPE := Release
SCRIPT := ./init.sh
VERBOSE_FLAG := VERBOSE=1

# Targets
.PHONY: all build clean rebuild build-all init asan tsan global_build

all: build-all

build-all:
@echo "==> Running initialization script..."
$(SCRIPT)
$(MAKE) build

build:
@echo "==> Fresh Building inLimbo with $(CMAKE_BUILD_TYPE)..."
$(CMAKE) -S . -B build $(BUILD_DIR)
$(CMAKE) --build $(BUILD_DIR)

rebuild:
@echo "==> Rebuilding inLimbo with $(CMAKE_BUILD_TYPE)..."
$(CMAKE) --build $(BUILD_DIR)

asan:
@echo "==> Building in AddressSanitizer mode..."
mkdir -p $(BUILD_DIR)
cd $(BUILD_DIR) && $(CMAKE) -DCMAKE_BUILD_TYPE=Debug-ASan .. && $(NINJA)

asan_run: asan
@echo "==> Running AddressSanitizer build..."
$(BUILD_DIR)/inLimbo-DBG-Asan

tsan:
@echo "==> Building in ThreadSanitizer mode..."
mkdir -p $(BUILD_DIR)
cd $(BUILD_DIR) && $(CMAKE) -DCMAKE_BUILD_TYPE=Debug-TSan .. && $(NINJA)

tsan_run: tsan
@echo "==> Running ThreadSanitizer build..."
$(BUILD_DIR)/inLimbo-DBG-TSan

clean:
@echo "==> Cleaning build directory..."
rm -rf $(BUILD_DIR)

init:
@echo "==> Running initialization script..."
$(SCRIPT)

global_build:
@echo "==> Building globally and installing..."
mkdir -p $(BUILD_DIR)
cd $(BUILD_DIR) && $(CMAKE) -DCMAKE_BUILD_TYPE=$(CMAKE_BUILD_TYPE) -DBUILD_GLOBAL=ON .. && $(NINJA)
cd $(BUILD_DIR) && sudo ninja install

verbose:
@echo "==> Building with verbose output..."
mkdir -p $(BUILD_DIR)
cd $(BUILD_DIR) && $(CMAKE) -DCMAKE_BUILD_TYPE=$(CMAKE_BUILD_TYPE) .. && $(NINJA) $(VERBOSE_FLAG)
67 changes: 39 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

----

> [!IMPORTANT]
> [!WARNING]
>
> inLimbo is a WIP
>
Expand Down Expand Up @@ -89,7 +89,43 @@ Here are a few novelties that may or may not have been added yet:
## BUILDING
You will need CMake for this (and git obvi)
You will need CMake and Make (GNU Make for BSD) for this (and git obvi)
### **USING MAKE** (Preferred):
The following Make commands will make building inLimbo very easy:
```bash
make all # to build EVERYTHING from scratch (and RUNS ./init.sh)
```
```bash
make build # A fresh build of inLimbo (DOES NOT RUN ./init.sh)
```

```bash
make rebuild # A quick rebuild of the project (DOES NOT RUN ./init.sh)
```

```bash
make init # Runs the init script to download required headers
```

```bash
make clean # wipes the build clean.
```

> [!NOTE]
>
> Debug building using make needs to be setup, will be available soon.
>
### **MANUAL BUILD**:

> [!WARNING]
>
> Proceed with manual build **ONLY** if you know what you are doing.
>
```bash
git clone https://github.com/nots1dd/inLimbo.git
Expand Down Expand Up @@ -202,32 +238,7 @@ There is quite a lot to configure in the inLimbo project. A basic config file wi

## DIRECTORY SORTING

Currently uses `rbtrees` and `unordered_map` to store and write the current inodes in given directory to `lib.sync` file

-> rbtree will contain all the inodes at runtime

-> cached to `lib.sync` for future use and faster data fetch

To test out the creation of the song map of your chosen directory:

```bash
cd src/dirsort/
make
./dirsort-test # change the directory in $HOME/.config/inLimbo/config.toml to test out
```

> [!NOTE]
>
> src/dirsort/ has the current implementation of
> how the chosen songs directory will be cached and
> read into memory to display in ftxui TUI
>
> To use dirsort/ source files separately:
>
> ```bash
> make
> ```
>
To know more about inLimbo Project's logical flow on creating a song map, visit [SONGMAP](https://github.com/nots1dd/inLimbo/blob/main/src/dirsort/SONGMAP.md)

## DOCUMENTATION

Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.2 - ALPHA
2.3 - ALPHA
1 change: 1 addition & 0 deletions assets/completions/inLimbo-completions.bash
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ _inLimbo_completions() {
"--show-config-file Show the configuration file path"
"--show-log-dir Show the log directory path"
"--show-dbus-name Show the DBus service name"
"--update-cache-run Update the cache file and run the application"
)

# Provide completion for options
Expand Down
3 changes: 2 additions & 1 deletion assets/completions/inLimbo-completions.fish
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ function _inLimbo_completions
"--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"
"--show-dbus-name" "Show the DBus service name" \
"--update-cache-run" "Update the cache file and run the application"
for i in (seq 1 2 (count $opts))
set -l opt (string trim -- $opts[$i])
set -l desc $opts[(math $i + 1)]
Expand Down
1 change: 1 addition & 0 deletions assets/completions/inLimbo-completions.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ _inLimbo_completions() {
"--show-config-file:Show the configuration file path"
"--show-log-dir:Show the log directory path"
"--show-dbus-name:Show the DBus service name"
"--update-cache-run:Update the cache file and run the application"
)
_describe -t options "inLimbo options" opts
}
Expand Down
6 changes: 6 additions & 0 deletions init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ show_msg() {
local target_dir=$3
local filename=$(basename "$url")

if [[ -f "$target_dir/$filename" ]]; then
echo -e "${GREEN}${filename} already exists in ${target_dir}, skipping download.${RESET}"
print_delim
return 0
fi

print_delim
echo -e "${YELLOW}${message}${RESET}"
echo -e "${CYAN}Downloading to ${target_dir}...${RESET}"
Expand Down
18 changes: 15 additions & 3 deletions src/arg-handler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@

// Constants
constexpr const char* DBUS_SERVICE_NAME = "org.mpris.MediaPlayer2.inLimbo";
constexpr const char* VERSION = "2.2 (ALPHA)";
constexpr const char* VERSION = "2.3 (ALPHA)";

bool shouldRunApp = false;

enum class ConsoleColor
{
Expand Down Expand Up @@ -56,14 +58,16 @@ class ArgumentHandler
{"--clear-cache", [&]() { handleClearCache(paths.libBinPath); }},
{"--show-config-file", [&]() { handleShowConfig(paths.configPath); }},
{"--show-log-dir", [&]() { handleShowLogDir(paths.cacheDir); }},
{"--show-dbus-name", [&]() { handleShowDBusName(); }}};
{"--show-dbus-name", [&]() { handleShowDBusName(); }},
{"--update-cache-run", [&]() { handleUpdateCacheRun(paths.libBinPath); }}};

for (const auto& [flag, handler] : argumentHandlers)
{
if (cmdArgs.hasFlag(flag))
{
handler();
exit(0);
if (!shouldRunApp)
exit(0);
}
}
}
Expand Down Expand Up @@ -116,6 +120,14 @@ class ArgumentHandler
colorPrint(ConsoleColor::Red, "Error clearing cache: ", e.what());
}
}

static void handleUpdateCacheRun(const std::string& libBinPath)
{
std::cout << ColorManager::getColor(ConsoleColor::Blue) << "-- Updating Cache and running app..." << ColorManager::getColor(ConsoleColor::Reset) << std::endl;
handleClearCache(libBinPath);
shouldRunApp = true;
}

};

#endif // ARGUMENT_HANDLER_HPP
16 changes: 15 additions & 1 deletion src/cmd-line-args.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,20 @@ class CommandLineArgs
std::cout << " " << flag << "\n";
}
}

std::cout << "\n";

// Project details and additional information
std::cout << "\033[1mProject Information:\033[0m\n";
std::cout << "- Name: inLimbo - Terminal-based Music Player\n";
std::cout << "- Author: Siddharth Karnam (nots1dd)\n";
std::cout << "- License: GNU GPL v3\n";
std::cout << "- Website: https://nots1dd.github.io/inLimbo/ (has Doxygen documentation)\n";
std::cout << "For any issues visit <https://github.com/nots1dd/inLimbo>\n";
std::cout << std::endl;

std::cout << "\033[1mDescription:\033[0m\n";
std::cout << " inLimbo is a TUI music player that supports seamless playback and efficient metadata handling.\n Designed for minimalism and ease of use.\n\n\033[1mKeeps YOU in Limbo...\033[0m";
std::cout << "\n";
}

Expand Down Expand Up @@ -133,6 +147,6 @@ class CommandLineArgs
// Define valid flags globally
const std::vector<std::string> CommandLineArgs::validFlags = {
"--help", "--show-dbus-name", "--version",
"--clear-cache", "--show-config-file", "--show-log-dir"};
"--clear-cache", "--show-config-file", "--show-log-dir", "--update-cache-run"};

#endif // COMMAND_LINE_ARGS_HPP
5 changes: 4 additions & 1 deletion src/dirsort/taglib_parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,15 @@ struct Metadata
std::string album = "Unknown Album"; /**< The album the song is part of */
std::string genre = "Unknown Genre"; /**< The genre of the song */
std::string comment = "No Comment"; /**< The comment associated with the song */
std::string fileType = "NULL";
unsigned int year = 0; /**< The year of release */
unsigned int track = 0; /**< The track number */
unsigned int discNumber = 0; /**< The disc number in a multi-disc set */
std::string lyrics = "No Lyrics"; /**< The lyrics of the song */
std::unordered_map<std::string, std::string> additionalProperties; /**< Any additional properties from the song's metadata */
std::string filePath; /**< The file path of the song */
float duration = 0.0f; /**< The duration of the song in seconds */
int bitrate = 0; /**< The bitrate of the song (not calculated) */

/**
* @brief Serialization function for Metadata.
Expand All @@ -58,7 +60,7 @@ struct Metadata
template <class Archive>
void serialize(Archive& ar)
{
ar(title, artist, album, genre, comment, year, track, discNumber, lyrics, additionalProperties, filePath, duration);
ar(title, artist, album, genre, comment, year, track, discNumber, lyrics, additionalProperties, filePath, duration, bitrate);
}
};

Expand Down Expand Up @@ -164,6 +166,7 @@ bool TagLibParser::parseFile(const std::string& filePath, Metadata& metadata) {
TagLib::AudioProperties *audioProperties = file.audioProperties();
if (audioProperties) {
metadata.duration = audioProperties->length(); // Duration in seconds
metadata.bitrate = (audioProperties->bitrate() == 0) ? -1 : audioProperties->bitrate();
}

// Keep track of file path
Expand Down
1 change: 1 addition & 0 deletions src/music/audio_playback.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ class MiniAudioPlayer
}
});
}
mtx.unlock();
}

/**
Expand Down
4 changes: 4 additions & 0 deletions src/parser/examples/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ album_name_bg = "#83A598" # Muted cyan for background

# Menu Cursor
menu_cursor_bg = "#8EC07C" # Soft green for cursor background
inactive_cursor_bg = "#FFADDF"

# Artists Title Section
artists_title_bg = "#458588" # Deep teal for background
Expand All @@ -80,3 +81,6 @@ volume_bar_col = "#8EC07C" # Soft green for volume bar
status_bar_bg = "#504945" # Dark gray for background
status_bar_artist_col = "#FB4934" # Bright red for artist name
status_bar_song_col = "#FABD2F" # Bright yellow for song name

[ui]
show_bitrate = "true"
2 changes: 2 additions & 0 deletions src/parser/toml_parser.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ namespace fs = std::filesystem;

#define PARENT_COLORS "colors" /**< Parent section for color settings */

#define PARENT_UI "ui" /**< Parent section for ui settings */

/**
* @brief Retrieves the path to the configuration file.
*
Expand Down
2 changes: 2 additions & 0 deletions src/ui/colors.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ struct InLimboColors
ftxui::Color inactive_win_border_color;
ftxui::Color album_name_bg;
ftxui::Color menu_cursor_bg;
ftxui::Color inactive_menu_cursor_bg;
ftxui::Color artists_title_bg;
ftxui::Color artists_title_fg;
ftxui::Color songs_title_bg;
Expand Down Expand Up @@ -314,6 +315,7 @@ InLimboColors parseColors()
{"inactive_win_border_color", &colors.inactive_win_border_color},
{"album_name_bg", &colors.album_name_bg},
{"menu_cursor_bg", &colors.menu_cursor_bg},
{"inactive_menu_cursor_bg", &colors.inactive_menu_cursor_bg},
{"artists_title_bg", &colors.artists_title_bg},
{"artists_title_fg", &colors.artists_title_fg},
{"songs_title_bg", &colors.songs_title_bg},
Expand Down
Loading

0 comments on commit dee3e71

Please # to comment.