Add jetbrains icons to project search

This commit is contained in:
Sage Vaillancourt 2023-02-18 18:10:10 -05:00
parent fbea6384b5
commit 6c464b87df
2 changed files with 21 additions and 11 deletions

View File

@ -19,6 +19,9 @@ configuration {
window {
display-name: "";
}
projects {
display-name: "";
}
tabs {
display-name: "";
fallback-icon: "firefox-beta";

View File

@ -5,12 +5,16 @@ GIT_DIRS=("$HOME/work" "$HOME/projects" "$HOME/git" "$HOME/WebStormProjects" "$H
function open_app() {
application="$1"
project="$2"
exe=$(grep "Exec" "$HOME/.local/share/applications/jetbrains-$application.desktop" | sed 's/.*"\([^"]*\)".*/\1/')
$exe "$project" &> /dev/null &
}
function get_icon {
application=$1
grep "Icon" "$HOME/.local/share/applications/jetbrains-$application.desktop" | sed 's/Icon=//'
}
function file_exists() {
project="$1"
file="$2"
@ -22,32 +26,35 @@ function file_exists() {
fi
}
function open_project() {
function get_project_type() {
project="$1"
if file_exists "$project" "pom.xml"; then
open_app "idea" "$project"
echo "idea"
elif file_exists "$project" "package.json"; then
open_app "webstorm" "$project"
echo "webstorm"
elif file_exists "$project" "cargo.toml" || file_exists "$project" "*.c"; then
open_app "clion" "$project"
echo "clion"
elif file_exists "$project" "*.csproj"; then
open_app "rider" "$project"
echo "rider"
elif file_exists "$project" "*.py"; then
open_app "pycharm" "$project"
echo "pycharm"
elif file_exists "$project" "*.go"; then
open_app "goland" "$project"
echo "goland"
else
open_app "idea" "$project"
echo "idea"
fi
}
if [[ "$1" == "" ]]; then
for dir in $(echo ${GIT_DIRS[*]}); do
if [ -e "$dir" ]; then
find $dir -maxdepth 1 -mindepth 1 -type d
projects=$(find $dir -maxdepth 1 -mindepth 1 -type d)
for project in $projects; do
echo -en "$project\0icon\x1f$(get_icon "$(get_project_type "$project")")\n"
done
fi
done
else
open_project "$1"
open_app "$(get_project_type "$1")" "$1"
fi