Skip to content

Commit

Permalink
Merge branch 'main' into luajit
Browse files Browse the repository at this point in the history
  • Loading branch information
wins1ey authored Apr 11, 2024
2 parents 1f35980 + 81e501f commit 758c521
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 37 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ jobs:
sudo apt -y update
sudo apt -y install libgtk-3-dev libx11-dev libjansson-dev libluajit-5.1-dev
- name: "Run make clean and make"
run: make clean && make -j
- name: "Run make"
run: make -j

- name: Set Build number
shell: bash
Expand Down
56 changes: 31 additions & 25 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
TARGET := LAST
BIN := LAST

INC := `pkg-config --cflags gtk+-3.0 x11 jansson luajit`
CFLAGS := -std=gnu99 -O2 -pthread -Wall -Wno-unused-parameter
Expand All @@ -13,19 +13,24 @@ COMPONENTS := $(wildcard $(SRC_DIR)/components/*.c)
OBJECTS := $(patsubst $(SRC_DIR)/%.c, $(OBJ_DIR)/%.o, $(SOURCES)) \
$(patsubst $(SRC_DIR)/components/%.c, $(OBJ_DIR)/%.o, $(COMPONENTS))

BIN := last
BIN_DIR := /usr/local/bin
DESTDIR :=
PREFIX := /usr/local
APP := last.desktop
APP_DIR := /usr/share/applications
ICON := last
ICON_DIR := /usr/share/icons/hicolor
SCHEMA := last.gschema.xml
SCHEMAS_DIR := /usr/share/glib-2.0/schemas

build: last-gtk.h $(TARGET)
ifdef DESTDIR
update_icon_cache :=
compile_schemas :=
else
update_icon_cache := gtk-update-icon-cache -f -t $(PREFIX)/share/icons/hicolor
compile_schemas := glib-compile-schemas $(PREFIX)/share/glib-2.0/schemas
endif

all: last-gtk.h $(BIN)

# Rule to link object files to create executable
$(TARGET): $(OBJECTS)
$(BIN): $(OBJECTS)
gcc $(CFLAGS) $^ $(LDFLAGS) -o $@

# Rule to compile C source files to object files
Expand All @@ -41,32 +46,33 @@ $(OBJ_DIR):
mkdir -p $(OBJ_DIR)

last-gtk.h: $(SRC_DIR)/last-gtk.css
xxd --include $(SRC_DIR)/last-gtk.css > $(SRC_DIR)/last-gtk.h || (rm $(SRC_DIR)/last-gtk.h; false)
xxd --include $(SRC_DIR)/last-gtk.css > $(SRC_DIR)/last-gtk.h || ($(RM) $(SRC_DIR)/last-gtk.h; false)

install:
cp $(TARGET) $(BIN_DIR)/$(BIN)
cp $(APP) $(APP_DIR)
install: all
install -Dm755 $(BIN) $(DESTDIR)$(PREFIX)/bin/$(BIN)
install -Dm644 $(APP) $(DESTDIR)$(PREFIX)/share/applications/$(APP)
for size in 16 22 24 32 36 48 64 72 96 128 256 512; do \
convert $(ICON).svg -resize "$$size"x"$$size" \
$(ICON_DIR)/"$$size"x"$$size"/apps/$(ICON).png ; \
mkdir -p $(DESTDIR)$(PREFIX)/share/icons/hicolor/"$$size"x"$$size"/apps ; \
rsvg-convert -w "$$size" -h "$$size" -f png -o $(DESTDIR)$(PREFIX)/share/icons/hicolor/"$$size"x"$$size"/apps/$(ICON).png $(ICON).svg ; \
done
gtk-update-icon-cache -f -t $(ICON_DIR)
cp $(SRC_DIR)/$(SCHEMA) $(SCHEMAS_DIR)
glib-compile-schemas $(SCHEMAS_DIR)

$(update_icon_cache)
install -Dm644 $(SRC_DIR)/$(SCHEMA) $(DESTDIR)$(PREFIX)/share/glib-2.0/schemas/$(SCHEMA)
$(compile_schemas)
install -Dm644 resources/themes/standard/standard.css $(DESTDIR)$(PREFIX)/share/LAST/themes/standard/standard.css
uninstall:
rm -f $(BIN_DIR)/$(BIN)
rm -f $(APP_DIR)/$(APP)
$(RM) $(DESTDIR)$(PREFIX)/bin/$(BIN)
$(RM) $(DESTDIR)$(PREFIX)/share/applications/$(APP)
$(RM) -r $(DESTDIR)$(PREFIX)/share/LAST
for size in 16 22 24 32 36 48 64 72 96 128 256 512; do \
rm -f $(ICON_DIR)/"$$size"x"$$size"/apps/$(ICON).png ; \
$(RM) $(DESTDIR)$(PREFIX)/share/icons/hicolor/"$$size"x"$$size"/apps/$(ICON).png ; \
done

remove-schema:
rm $(SCHEMAS_DIR)/$(SCHEMA)
glib-compile-schemas $(SCHEMAS_DIR)
$(RM) $(DESTDIR)$(PREFIX)/share/glib-2.0/schemas/$(SCHEMA)
$(compile_schemas)

# Clean target to remove object files and LAS executable
clean:
rm -rf $(TARGET) $(OBJ_DIR) $(SRC_DIR)/last-gtk.h
$(RM) -r $(BIN) $(OBJ_DIR) $(SRC_DIR)/last-gtk.h

.PHONY: build last-gtk.h install uninstall remove-schema clean
.PHONY: all last-gtk.h install uninstall remove-schema clean
13 changes: 7 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,17 @@ LAST requires the following dependencies on your system to compile:
- `libjansson`
- `luajit`

And to install:

- `imagemagick`

## Installation

```bash
git clone https://github.com/Wins1ey/LAST
git clone --recurse-submodules https://github.com/wins1ey/LAST
cd LAST
sudo make build install
make
sudo make install
```
or
```bash
git clone --recurse-submodules https://github.com/wins1ey/LAST && cd LAST && make && sudo make install
```

## Getting Started
Expand Down
2 changes: 1 addition & 1 deletion last.desktop
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[Desktop Entry]
Name=LAST
Exec=/usr/local/bin/last
Exec=LAST
Icon=last
Type=Application
Categories=GTK;GNOME;Utility;
11 changes: 8 additions & 3 deletions src/last-gtk.c
Original file line number Diff line number Diff line change
Expand Up @@ -227,12 +227,17 @@ static int last_app_window_find_theme(LASTAppWindow *win,
strcat(str, theme_path);
if (stat(str, &st) == -1)
{
strcpy(str, "/usr/share/last/themes");
strcpy(str, "/usr/share/LAST/themes");
strcat(str, theme_path);
if (stat(str, &st) == -1)
{
str[0] = '\0';
return 0;
strcpy(str, "/usr/local/share/LAST/themes");
strcat(str, theme_path);
if (stat(str, &st) == -1)
{
str[0] = '\0';
return 0;
}
}
}
return 1;
Expand Down

0 comments on commit 758c521

Please sign in to comment.