浏览代码

some code fixes

milan jurkulák 2 年之前
父节点
当前提交
777ff06012

+ 6 - 0
.github/workflows/build-gradle-project.yml

@@ -43,6 +43,12 @@ jobs:
       - name: Build Release
         id: build_release
         run: ./gradlew --stacktrace clean createPackages
+      # generate version number to env
+      - name: Prepare Version Number
+        id: prepare_version
+        run: |
+          export $APP_VERSION=$(date '+%Y-%m-%d');
+          echo "GITHUB_APP_VERSION_NAME=$(echo $APP_VERSION)" >> $GITHUB_ENV
       # publish package release
       - name: Create Release
         id: release

+ 2 - 1
src/main/kotlin/eu/mjdev/desktop/components/desktoppanel/DesktopPanelIcon.kt

@@ -12,6 +12,7 @@ import androidx.compose.ui.unit.DpSize
 import androidx.compose.ui.unit.dp
 import eu.mjdev.desktop.components.fonticon.FontIcon
 import eu.mjdev.desktop.data.App
+import eu.mjdev.desktop.data.App.Companion.rememberRunningIndicator
 import eu.mjdev.desktop.extensions.Compose.color
 import eu.mjdev.desktop.extensions.Compose.noElevation
 import eu.mjdev.desktop.extensions.Compose.onLeftClick
@@ -50,7 +51,7 @@ fun DesktopPanelIcon(
         else -> Color.Transparent
     }
     val isStarting by rememberCalculated(app) { app?.isStarting ?: false }
-    val isRunning by rememberCalculated(app) { app?.isRunning ?: false }
+    val isRunning by rememberRunningIndicator(app)
     Box(
         modifier = Modifier
             .size(iconSize)

+ 38 - 8
src/main/kotlin/eu/mjdev/desktop/data/App.kt

@@ -1,8 +1,9 @@
 package eu.mjdev.desktop.data
 
-import androidx.compose.runtime.MutableState
-import androidx.compose.runtime.mutableStateOf
+import androidx.compose.runtime.*
 import androidx.compose.ui.graphics.Color
+import eu.mjdev.desktop.extensions.Custom.command
+import eu.mjdev.desktop.extensions.Custom.commandLine
 import eu.mjdev.desktop.helpers.exception.EmptyException.Companion.EmptyException
 import eu.mjdev.desktop.helpers.system.Shell
 import eu.mjdev.desktop.provider.DesktopProvider
@@ -41,6 +42,18 @@ class App(
     val windowClass
         get() = desktopFile?.desktopSection?.StartupWMClass.orEmpty().ifEmpty { fullAppName }
 
+    val cmd
+        get() = exec.split(" ").first()
+
+    val hasProcess: Boolean = ProcessHandle.allProcesses().toList().any { ph ->
+        ph.command.contentEquals(windowClass, true) ||
+                ph.command.contains(cmd, true) ||
+                ph.command.contains(name, true) ||
+                ph.commandLine.contentEquals(windowClass, true) ||
+                ph.commandLine.contains(cmd, true) ||
+                ph.commandLine.contains(name, true)
+    }
+
     var iconTint: Color? = null
     val iconBackground: Color = Color.White
 
@@ -134,7 +147,7 @@ class App(
         result = 31 * result + (desktopFile?.hashCode() ?: 0)
         result = 31 * result + isFavorite.hashCode()
         result = 31 * result + (fileName?.hashCode() ?: 0)
-        result = 31 * result + (fullAppName.hashCode())
+        result = 31 * result + fullAppName.hashCode()
         result = 31 * result + type.hashCode()
         result = 31 * result + version.hashCode()
         result = 31 * result + name.hashCode()
@@ -145,14 +158,13 @@ class App(
         result = 31 * result + categories.hashCode()
         result = 31 * result + notifyOnStart.hashCode()
         result = 31 * result + runInTerminal.hashCode()
-        result = 31 * result + (windowClass.hashCode())
+        result = 31 * result + windowClass.hashCode()
+        result = 31 * result + cmd.hashCode()
+        result = 31 * result + hasProcess.hashCode()
         result = 31 * result + (iconTint?.hashCode() ?: 0)
         result = 31 * result + iconBackground.hashCode()
-        result = 31 * result + onStopHandler.hashCode()
-        result = 31 * result + onStartingHandler.hashCode()
-        result = 31 * result + onStartedHandler.hashCode()
-        result = 31 * result + isStartingState.hashCode()
         result = 31 * result + isStarting.hashCode()
+        result = 31 * result + isRunning.hashCode()
         return result
     }
 
@@ -168,5 +180,23 @@ class App(
                 else -> list
             }
         }
+
+        @Composable
+        fun rememberRunningIndicator(app: App?) = remember(
+            app,
+            app?.isFavorite,
+            app?.isRunning,
+            app?.isStarting
+        ) {
+            RunningAppIndicator(app)
+        }
+
+        // todo
+        class RunningAppIndicator(
+            val app: App?
+        ) : State<Boolean> {
+            override val value: Boolean
+                get() = app?.isRunning == true || app?.hasProcess == true
+        }
     }
 }

+ 2 - 0
src/main/kotlin/eu/mjdev/desktop/theme/gtk/GtkThemeHelper.kt

@@ -251,6 +251,8 @@ class GtkThemeHelper(
             }
             
             .titlebar, headerbar {
+                padding-top: 2px;
+                padding-bottom: 2px;
                 background-image: none;
                 background-color: ${bgColor.hexRgb};
             }