Skip to content

Commit 9f05e54

Browse files
authored
Merge pull request #142 from kurwjan/flathub-support
Testing Snapcraft support by kurwjan
2 parents 0109160 + 1218dc3 commit 9f05e54

File tree

13 files changed

+133
-81
lines changed

13 files changed

+133
-81
lines changed

.github/workflows/build.yml

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -301,24 +301,25 @@ jobs:
301301
302302
cp /usr/lib/x86_64-linux-gnu/libsecret-1.so* AppDir/usr/lib/ || true
303303
304-
cp assets/images/logo/logo_blue_big_abs.png AppDir/usr/share/icons/hicolor/256x256/apps/buchable.png
305-
cp assets/images/logo/logo_blue_big_abs.png AppDir/buchable.png
304+
cp assets/images/logo/logo_blue_big_abs.png AppDir/usr/share/icons/hicolor/256x256/apps/io.github.vito0912.abs_flutter.png
305+
cp assets/images/logo/logo_blue_big_abs.png AppDir/io.github.vito0912.abs_flutter.png
306306
307-
cat > AppDir/buchable.desktop << EOL
307+
cat > AppDir/io.github.vito0912.abs_flutter.desktop << EOL
308308
[Desktop Entry]
309309
Name=Buchable
310-
Comment=The unofficial cross-platform app for Audiobookshelf
311-
Exec=abs_flutter
312-
Icon=buchable
313-
Terminal=false
310+
Comment=Enjoy hearing self-hosted audiobooks.
311+
Exec=buchable
314312
Type=Application
315-
Categories=Audio;AudioVideo;Player;
316-
StartupWMClass=buchable
317-
X-GNOME-UsesNotifications=true
313+
Icon=io.github.vito0912.abs_flutter.png
314+
Terminal=false
315+
Keywords=Audiobook,Player,Audiobookshelf,Listen;
316+
Categories=Multimedia;Audio;AudioVideo;Player;
318317
MimeType=audio/*;video/*;
318+
X-GNOME-UsesNotifications=true
319+
StartupWMClass=buchable
319320
EOL
320321
321-
cp AppDir/buchable.desktop AppDir/usr/share/applications/
322+
cp AppDir/io.github.vito0912.abs_flutter.desktop AppDir/usr/share/applications/
322323
323324
cat > AppDir/AppRun << EOL
324325
#!/bin/sh
@@ -384,7 +385,7 @@ jobs:
384385
mv ubuntu-artifacts/app-release.apk ubuntu-artifacts/android-release-${{ env.VERSION }}.apk
385386
mv ubuntu-artifacts/app-release.aab ubuntu-artifacts/android-release-${{ env.VERSION }}.aab
386387
mv ubuntu-artifacts/web-release.zip ubuntu-artifacts/web-release-${{ env.VERSION }}.zip
387-
mv linux-artifacts/linux-release.zip linux-artifacts/linux-release-${{ env.VERSION }}.zip
388+
mv linux-artifacts/linux-release.zip linux-artifacts/linux-release.zip
388389
mv linux-artifacts/buchable-${{ env.VERSION }}-x86_64.AppImage linux-artifacts/buchable-${{ env.VERSION }}-x86_64.AppImage || true
389390
390391
- name: Create GitHub Release
@@ -403,7 +404,7 @@ jobs:
403404
windows-artifacts/windows-Release-${{ env.VERSION }}.zip
404405
windows-artifacts/windows-installer-release-${{ env.VERSION }}.msix
405406
windows-artifacts/windows-installer-release-${{ env.VERSION }}-store.msix
406-
linux-artifacts/linux-release-${{ env.VERSION }}.zip
407+
linux-artifacts/linux-release.zip
407408
linux-artifacts/buchable-${{ env.VERSION }}-x86_64.AppImage
408409
409410
publish-release:

lib/main.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import 'package:flutter_settings_screens/flutter_settings_screens.dart';
2121
import 'package:intl/date_symbol_data_local.dart';
2222
import 'package:just_audio_media_kit/just_audio_media_kit.dart';
2323
import 'package:package_info_plus/package_info_plus.dart';
24-
import 'package:path/path.dart' as path;
2524
import 'package:path/path.dart';
2625
import 'package:path_provider/path_provider.dart';
2726
import 'package:sembast/sembast_io.dart';
@@ -45,7 +44,7 @@ void main() async {
4544

4645
if (!kIsWeb) {
4746
appDir = Platform.isLinux
48-
? '${path.join('/home', Platform.environment['USER']!, '.abs_flutter')}'
47+
? (await getApplicationSupportDirectory()).path
4948
: '${(await getApplicationDocumentsDirectory()).path.replaceAll('\\', '/')}/abs_flutter';
5049

5150
await Directory(appDir).create(recursive: true);

lib/provider/download_provider.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import 'package:abs_flutter/provider/user_provider.dart';
88
import 'package:collection/collection.dart';
99
import 'package:flutter/foundation.dart';
1010
import 'package:flutter_riverpod/flutter_riverpod.dart';
11+
import 'package:path_provider/path_provider.dart';
1112
import 'package:saf_util/saf_util.dart';
1213
import 'package:saf_util/saf_util_platform_interface.dart';
1314
import 'package:path/path.dart' as path;
@@ -56,10 +57,9 @@ class DownloadListNotifier extends StateNotifier<List<DownloadInfo>> {
5657
_saveDownloads();
5758
}
5859

59-
String _getDownloadPath(DownloadInfo download) {
60+
Future<String> _getDownloadPath(DownloadInfo download) async {
6061
if ( !kIsWeb && Platform.isLinux) {
61-
final homeDir = Directory(path.join('/home', Platform.environment['USER']!));
62-
return path.join(homeDir.path, '.abs_flutter', download.folderPath);
62+
return path.join((await getApplicationSupportDirectory()).path, download.folderPath);
6363
}
6464
return download.folderPath;
6565
}
@@ -102,7 +102,7 @@ class DownloadListNotifier extends StateNotifier<List<DownloadInfo>> {
102102
log('Error deleting file: $e', name: 'removeDownload');
103103
}
104104
} else {
105-
final folder = Directory(_getDownloadPath(download));
105+
final folder = Directory(await _getDownloadPath(download));
106106
// For windows support / and \ in path
107107
final folderName = folder.path.replaceAll('\\', '/').split('/').last;
108108
if (folderName == download.itemId || folderName == download.episodeId) {

lib/provider/downloader_provider.dart

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,7 @@ class DownloadProvider extends ChangeNotifier {
166166
String path = await update.task.filePath();
167167

168168
if (!kIsWeb && Platform.isLinux) {
169-
String homeDir = '/home/${Platform.environment['USER']}';
170-
path = path.replaceFirst('/.abs_flutter', '$homeDir/.abs_flutter');
169+
path = (await getApplicationSupportDirectory()).path;
171170
}
172171

173172
Directory(path).parent.deleteSync(recursive: true);
@@ -400,8 +399,7 @@ class DownloadProvider extends ChangeNotifier {
400399
Directory? homeDir;
401400

402401
if (!kIsWeb && Platform.isLinux) {
403-
final homeDir = Platform.environment['USER'];
404-
savePath = path.join('/home', homeDir, '.abs_flutter');
402+
savePath = (await getApplicationSupportDirectory()).path;
405403

406404
if (episodeId != null) {
407405
savePath = path.join(savePath, itemId, episodeId);

linux/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ project(runner LANGUAGES CXX)
77
set(BINARY_NAME "abs_flutter")
88
# The unique GTK application identifier for this application. See:
99
# https://wiki.gnome.org/HowDoI/ChooseApplicationID
10-
set(APPLICATION_ID "de.vito.absapp.abs_flutter")
10+
set(APPLICATION_ID "io.github.vito0912.abs_flutter")
1111

1212
# Explicitly opt in to modern CMake behaviors to avoid warnings with recent
1313
# versions of CMake.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<component type="desktop-application">
3+
<id>io.github.vito0912.abs_flutter</id>
4+
5+
<name>Buchable</name>
6+
<summary>Enjoy hearing self-hosted audiobooks.</summary>
7+
8+
<metadata_license>CC0-1.0</metadata_license>
9+
<project_license>BSD-3-Clause</project_license>
10+
11+
<supports>
12+
<control>pointing</control>
13+
<control>keyboard</control>
14+
<control>touch</control>
15+
</supports>
16+
17+
<description>
18+
<p>
19+
test
20+
</p>
21+
</description>
22+
23+
<launchable type="desktop-id">io.github.vito0912.abs_flutter.desktop</launchable>
24+
</component>

linux/my_application.cc

Lines changed: 3 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -20,32 +20,7 @@ static void my_application_activate(GApplication* application) {
2020
GtkWindow* window =
2121
GTK_WINDOW(gtk_application_window_new(GTK_APPLICATION(application)));
2222

23-
// Use a header bar when running in GNOME as this is the common style used
24-
// by applications and is the setup most users will be using (e.g. Ubuntu
25-
// desktop).
26-
// If running on X and not using GNOME then just use a traditional title bar
27-
// in case the window manager does more exotic layout, e.g. tiling.
28-
// If running on Wayland assume the header bar will work (may need changing
29-
// if future cases occur).
30-
gboolean use_header_bar = TRUE;
31-
#ifdef GDK_WINDOWING_X11
32-
GdkScreen* screen = gtk_window_get_screen(window);
33-
if (GDK_IS_X11_SCREEN(screen)) {
34-
const gchar* wm_name = gdk_x11_screen_get_window_manager_name(screen);
35-
if (g_strcmp0(wm_name, "GNOME Shell") != 0) {
36-
use_header_bar = FALSE;
37-
}
38-
}
39-
#endif
40-
if (use_header_bar) {
41-
GtkHeaderBar* header_bar = GTK_HEADER_BAR(gtk_header_bar_new());
42-
gtk_widget_show(GTK_WIDGET(header_bar));
43-
gtk_header_bar_set_title(header_bar, "abs_flutter");
44-
gtk_header_bar_set_show_close_button(header_bar, TRUE);
45-
gtk_window_set_titlebar(window, GTK_WIDGET(header_bar));
46-
} else {
47-
gtk_window_set_title(window, "abs_flutter");
48-
}
23+
gtk_window_set_title(window, "Buchable");
4924

5025
gtk_window_set_default_size(window, 1280, 720);
5126
gtk_widget_show(GTK_WIDGET(window));
@@ -117,6 +92,8 @@ static void my_application_class_init(MyApplicationClass* klass) {
11792
static void my_application_init(MyApplication* self) {}
11893

11994
MyApplication* my_application_new() {
95+
g_set_prgname(APPLICATION_ID);
96+
12097
return MY_APPLICATION(g_object_new(my_application_get_type(),
12198
"application-id", APPLICATION_ID,
12299
"flags", G_APPLICATION_NON_UNIQUE,

pubspec.lock

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,12 @@ packages:
7272
audio_service_mpris:
7373
dependency: "direct main"
7474
description:
75-
name: audio_service_mpris
76-
sha256: b16db3584a4b2464c0bfd575c1a21765723d257931222f8adfcb0511f940d352
77-
url: "https://pub.dev"
78-
source: hosted
79-
version: "0.1.5"
75+
path: "."
76+
ref: ad6f743b73e320670449026fa1852d9978438bb9
77+
resolved-ref: ad6f743b73e320670449026fa1852d9978438bb9
78+
url: "https://github.com/Feichtmeier/audio-service-mpris"
79+
source: git
80+
version: "0.1.3"
8081
audio_service_platform_interface:
8182
dependency: transitive
8283
description:

pubspec.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,10 @@ dependencies:
3535
audio_service: ^0.18.15
3636
package_info_plus: ^8.0.1
3737
just_audio_windows: ^0.2.2
38-
audio_service_mpris: ^0.1.5
38+
audio_service_mpris:
39+
git:
40+
url: https://github.com/Feichtmeier/audio-service-mpris
41+
ref: ad6f743b73e320670449026fa1852d9978438bb9
3942
just_audio_media_kit: 2.0.3
4043
flutter_settings_screens: ^0.3.4
4144
device_info_plus: ^10.1.1

snap/gui/app_icon.desktop

Lines changed: 0 additions & 8 deletions
This file was deleted.

0 commit comments

Comments
 (0)