Skip to content

Commit 48b936d

Browse files
committed
:zip: Experimental dryrun option
1 parent e66f551 commit 48b936d

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

main.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,23 +26,26 @@ var (
2626

2727
Version string = "v0.1+"
2828
ShowVersion bool
29+
30+
DryRun bool
2931
)
3032

3133
func init() {
3234
flag.BoolVar(&SingleInstance, SIFlag, false, "Run an instance of projektor, not a daemon")
3335
flag.StringVar(&CPUProfile, "cpuprofile", "", "Run CPU profiling and output results to the `file`")
3436
flag.BoolVar(&ShowVersion, "V", false, "Display version of current projektor build.\n\tPlus sign means that the build includes several more commits over the release.")
37+
flag.BoolVar(&DryRun, "dry", false, "Prepare to run projektor instance but do not run (useful to force kernel caching).")
3538
}
3639

37-
func RunInstance() {
40+
func RunInstance(dry bool) {
3841
logf("Running single instance of projektor\n")
3942

4043
logf("Loading history...\n")
4144
LoadHistory()
4245
logf("Indexing desktop entries...\n")
4346
IndexDesktopEntries()
4447
logf("Set up the UI.\n")
45-
SetupUi()
48+
SetupUi(dry)
4649
}
4750

4851
func RunDaemon() {
@@ -93,7 +96,7 @@ func main() {
9396
}
9497

9598
if SingleInstance {
96-
RunInstance()
99+
RunInstance(DryRun)
97100
} else {
98101
RunDaemon()
99102
}

ui.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ func init() {
311311
runtime.LockOSThread()
312312
}
313313

314-
func SetupUi() {
314+
func SetupUi(dry bool) {
315315
logf("gtk.Init()\n")
316316
gtk.Init(&os.Args)
317317

@@ -422,8 +422,15 @@ func SetupUi() {
422422
logf("UpdateSearchResults()\n")
423423
UpdateSearchResults()
424424

425-
logf("ShowAll()\n")
426-
Ui.Window.ShowAll()
425+
if dry {
426+
logf("Defer MainQuit()\n")
427+
glib.IdleAdd(func() {
428+
gtk.MainQuit()
429+
})
430+
} else {
431+
logf("ShowAll()\n")
432+
Ui.Window.ShowAll()
433+
}
427434

428435
logf("gtk.Main()\n")
429436
gtk.Main()

0 commit comments

Comments
 (0)