-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
146 additions
and
123 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 2 additions & 3 deletions
5
src/nativeMain/kotlin/de/atennert/lcarsde/statusbar/configuration/readConfiguration.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
src/nativeMain/kotlin/de/atennert/lcarsde/statusbar/constants.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package de.atennert.lcarsde.statusbar | ||
|
||
const val CELL_SIZE = 40 | ||
const val GAP_SIZE = 8 | ||
|
||
const val LCARSDE_STATUS_BAR = "LCARSDE_STATUS_BAR" | ||
|
||
const val STYLE_PATH = "/usr/share/lcarsde/status-bar/style.css" |
28 changes: 28 additions & 0 deletions
28
src/nativeMain/kotlin/de/atennert/lcarsde/statusbar/executeCommand.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package de.atennert.lcarsde.statusbar | ||
|
||
import kotlinx.cinterop.* | ||
import statusbar.* | ||
|
||
fun executeCommand(command: String) { | ||
val commandParts = command.split(' ') | ||
|
||
val byteArgs = commandParts.map { it.encodeToByteArray().pin() } | ||
val convertedArgs = nativeHeap.allocArrayOfPointersTo(byteArgs.map { it.addressOf(0).pointed }) | ||
when (fork()) { | ||
-1 -> return | ||
0 -> { | ||
if (setsid() == -1) { | ||
perror("setsid failed") | ||
exit(1) | ||
} | ||
|
||
if (execvp(commandParts[0], convertedArgs) == -1) { | ||
perror("execvp failed") | ||
exit(1) | ||
} | ||
|
||
exit(0) | ||
} | ||
} | ||
byteArgs.map { it.unpin() } | ||
} |
20 changes: 20 additions & 0 deletions
20
src/nativeMain/kotlin/de/atennert/lcarsde/statusbar/extensions/gtkExtentions.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package de.atennert.lcarsde.statusbar.extensions | ||
|
||
import kotlinx.cinterop.CFunction | ||
import kotlinx.cinterop.CPointer | ||
import kotlinx.cinterop.reinterpret | ||
import statusbar.* | ||
|
||
fun <F : CFunction<*>> gSignalConnect(obj: CPointer<*>, actionName: String, action: CPointer<F>, | ||
data: gpointer? = null, connect_flags: GConnectFlags = 0u) { | ||
g_signal_connect_data(obj.reinterpret(), actionName, action.reinterpret(), data, | ||
destroy_data = null, connect_flags = connect_flags) | ||
} | ||
|
||
fun CPointer<GtkWidget>.setStyling(cssProvider: CPointer<GtkCssProvider>, vararg classes: String) { | ||
val styleContext = gtk_widget_get_style_context(this) | ||
for (cls in classes) { | ||
gtk_style_context_add_class(styleContext, cls) | ||
} | ||
gtk_style_context_add_provider(styleContext, cssProvider.reinterpret(), GTK_STYLE_PROVIDER_PRIORITY_USER) | ||
} |
35 changes: 35 additions & 0 deletions
35
src/nativeMain/kotlin/de/atennert/lcarsde/statusbar/extensions/stringExtensions.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package de.atennert.lcarsde.statusbar.extensions | ||
|
||
import kotlinx.cinterop.* | ||
import kotlinx.cinterop.toKString | ||
|
||
/** Convert string to byte array as used in X properties */ | ||
fun String.toUByteArray(): UByteArray { | ||
return this.encodeToByteArray().asUByteArray() | ||
} | ||
|
||
/** convert this ubyte array pointer to a string */ | ||
fun CPointer<UByteVar>.toKString(): String { | ||
val byteString = mutableListOf<Byte>() | ||
var i = 0 | ||
|
||
while (true) { | ||
val value = this[i] | ||
if (value.convert<Int>() == 0) { | ||
break | ||
} | ||
|
||
byteString.add(value.convert()) | ||
i++ | ||
} | ||
return byteString.toByteArray().toKString() | ||
} | ||
|
||
/** convert this ubyte array pointer to a string */ | ||
fun CPointer<UByteVar>?.toKString(): String = this?.toKString() ?: "" | ||
|
||
/** print a float with a certain amount of places */ | ||
fun Float.print(places: Int): String { | ||
val flString = this.toString().split('.', limit = 2) | ||
return "${flString[0]}.${flString[1].take(places)}" | ||
} |
20 changes: 20 additions & 0 deletions
20
src/nativeMain/kotlin/de/atennert/lcarsde/statusbar/readFile.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package de.atennert.lcarsde.statusbar | ||
|
||
import kotlinx.cinterop.addressOf | ||
import kotlinx.cinterop.toKString | ||
import kotlinx.cinterop.usePinned | ||
|
||
fun readFile(path: String): String? { | ||
platform.posix.fopen(path, "r")?. let { fp -> | ||
var s = "" | ||
val buf = ByteArray(1000) | ||
buf.usePinned { | ||
while (platform.posix.fgets(it.addressOf(0), 1000, fp) != null) { | ||
s += it.get().toKString() | ||
} | ||
} | ||
platform.posix.fclose(fp) | ||
return s.trim() | ||
} | ||
return null | ||
} |
95 changes: 0 additions & 95 deletions
95
src/nativeMain/kotlin/de/atennert/lcarsde/statusbar/stuff.kt
This file was deleted.
Oops, something went wrong.
5 changes: 4 additions & 1 deletion
5
src/nativeMain/kotlin/de/atennert/lcarsde/statusbar/widgets/AudioWidget.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/nativeMain/kotlin/de/atennert/lcarsde/statusbar/widgets/BatteryWidget.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/nativeMain/kotlin/de/atennert/lcarsde/statusbar/widgets/EmptyWidget.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/nativeMain/kotlin/de/atennert/lcarsde/statusbar/widgets/EthernetWidget.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/nativeMain/kotlin/de/atennert/lcarsde/statusbar/widgets/RadarGraphWidget.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/nativeMain/kotlin/de/atennert/lcarsde/statusbar/widgets/StardateWidget.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/nativeMain/kotlin/de/atennert/lcarsde/statusbar/widgets/StatusFillerWidget.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/nativeMain/kotlin/de/atennert/lcarsde/statusbar/widgets/TextWidget.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 1 addition & 2 deletions
3
src/nativeMain/kotlin/de/atennert/lcarsde/statusbar/widgets/WifiWidget.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters