Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
A
adormit
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
jrabbit
adormit
Commits
2944cb49
Commit
2944cb49
authored
7 years ago
by
jrabbit
Browse files
Options
Downloads
Patches
Plain Diff
actually be ready to write new variants to gsettings
parent
6abfd6db
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/adormit/adormit.go
+35
-11
35 additions, 11 deletions
src/adormit/adormit.go
src/cmd/root.go
+1
-0
1 addition, 0 deletions
src/cmd/root.go
with
36 additions
and
11 deletions
src/adormit/adormit.go
+
35
−
11
View file @
2944cb49
...
@@ -4,6 +4,7 @@ import (
...
@@ -4,6 +4,7 @@ import (
"fmt"
"fmt"
"github.com/godbus/dbus"
"github.com/godbus/dbus"
"github.com/gotk3/gotk3/glib"
"github.com/gotk3/gotk3/glib"
"os/exec"
"reflect"
"reflect"
"time"
"time"
)
)
...
@@ -21,6 +22,23 @@ type Timer struct {
...
@@ -21,6 +22,23 @@ type Timer struct {
start
time
.
Time
start
time
.
Time
duration
time
.
Duration
duration
time
.
Duration
end
time
.
Time
end
time
.
Time
command
string
args
[]
string
}
func
(
t
Timer
)
Countdown
()
{
timer1
:=
time
.
NewTimer
(
t
.
duration
)
<-
timer1
.
C
fmt
.
Println
(
"Timer completed"
)
t
.
end
=
time
.
Now
()
cmd
:=
exec
.
Command
(
t
.
command
,
t
.
args
...
)
cmd
.
Run
()
}
func
DemoTimer
()
{
args
:=
[]
string
{
"-i"
,
"clock"
,
"Timer over!"
,
"adormit"
}
t
:=
Timer
{
duration
:
time
.
Second
*
1
,
command
:
"notify-send"
,
args
:
args
}
t
.
Countdown
()
}
}
func
MakeAlarm
()
{
func
MakeAlarm
()
{
...
@@ -29,20 +47,18 @@ func MakeAlarm() {
...
@@ -29,20 +47,18 @@ func MakeAlarm() {
}
}
func
SetAlarm
(
alarm
Alarm
)
{
func
SetAlarm
(
alarm
Alarm
)
{
var
insert
[]
map
[
string
]
interface
{}
var
insert
[]
map
[
string
]
dbus
.
Variant
// insert := make(map[string]dbus.Variant)
a
:=
make
(
map
[
string
]
dbus
.
Variant
)
a
:=
make
(
map
[
string
]
interface
{})
a
[
"name"
]
=
dbus
.
MakeVariant
(
alarm
.
name
)
a
[
"name"
]
=
alarm
.
name
a
[
"active"
]
=
dbus
.
MakeVariant
(
alarm
.
active
)
a
[
"active"
]
=
alarm
.
active
existing_alarms
:=
GetGnomeAlarms
()
// existing_alarms := GetGnomeAlarms()
// total_update := make([]map[string]dbus.Variant, 10)
// total_update = append(total_update, insert)
// total_update = append(total_update, existing_alarms)
// total_update[2] = insert
insert
=
append
(
insert
,
a
)
insert
=
append
(
insert
,
a
)
for
_
,
v
:=
range
existing_alarms
{
insert
=
append
(
insert
,
v
)
}
// insert = append(insert, get_v().([]interface{})[0].(map[string]interface{}))
sig
,
_
:=
dbus
.
ParseSignature
(
"aa{sv}"
)
sig
,
_
:=
dbus
.
ParseSignature
(
"aa{sv}"
)
existing_alarms_var
:=
dbus
.
MakeVariantWithSignature
(
insert
,
sig
)
existing_alarms_var
:=
dbus
.
MakeVariantWithSignature
(
insert
,
sig
)
fmt
.
Println
(
existing_alarms_var
)
fmt
.
Println
(
existing_alarms_var
)
}
}
...
@@ -55,6 +71,14 @@ func debug(ty interface{}) {
...
@@ -55,6 +71,14 @@ func debug(ty interface{}) {
}
}
}
}
func
get_v
()
interface
{}
{
settings
:=
glib
.
SettingsNew
(
"org.gnome.clocks"
)
alarms
:=
settings
.
GetValue
(
"alarms"
)
sig
,
_
:=
dbus
.
ParseSignature
(
"aa{sv}"
)
v
,
_
:=
dbus
.
ParseVariant
(
alarms
.
String
(),
sig
)
return
v
.
Value
()
}
func
GetGnomeAlarms
()
[]
map
[
string
]
dbus
.
Variant
{
func
GetGnomeAlarms
()
[]
map
[
string
]
dbus
.
Variant
{
//gsettings get org.gnome.clocks alarms
//gsettings get org.gnome.clocks alarms
settings
:=
glib
.
SettingsNew
(
"org.gnome.clocks"
)
settings
:=
glib
.
SettingsNew
(
"org.gnome.clocks"
)
...
...
This diff is collapsed.
Click to expand it.
src/cmd/root.go
+
1
−
0
View file @
2944cb49
...
@@ -12,6 +12,7 @@ var RootCmd = &cobra.Command{
...
@@ -12,6 +12,7 @@ var RootCmd = &cobra.Command{
// cmd.Help()
// cmd.Help()
adormit
.
GetGnomeAlarms
()
adormit
.
GetGnomeAlarms
()
adormit
.
MakeAlarm
()
adormit
.
MakeAlarm
()
adormit
.
DemoTimer
()
},
},
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment