Skip to content

Commit 8615e8a

Browse files
committed
Update flake and catch up with recent AGS changes
* Mpris: Add MprisPlayer.metadata * App: Add FFI get and set methods for cursorTheme, iconTheme, gtkTheme
1 parent da1b471 commit 8615e8a

File tree

4 files changed

+93
-4
lines changed

4 files changed

+93
-4
lines changed

flake.lock

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/AGS/Service/App.js

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
1+
// Props
2+
3+
export const iconTheme =
4+
() =>
5+
App.iconTheme
6+
7+
export const cursorTheme =
8+
() =>
9+
App.cursorTheme
10+
11+
export const gtkTheme =
12+
() =>
13+
App.gtkTheme
14+
15+
export const configPath =
16+
() =>
17+
App.configPath
18+
119
export const configDir =
220
() =>
321
App.configDir
@@ -6,6 +24,8 @@ export const windows =
624
() =>
725
App.windows
826

27+
// Signals
28+
929
export const disconnectApp =
1030
handlerID => () =>
1131
App.disconnect(handlerID)
@@ -14,6 +34,24 @@ export const connectApp =
1434
signal => handler => () =>
1535
App.connect(signal, (_, ...args) => handler(...args))
1636

37+
// Methods
38+
39+
export const addIcons =
40+
path => () =>
41+
App.addIcons(path)
42+
43+
export const setIconTheme =
44+
theme => () =>
45+
App.iconTheme = theme
46+
47+
export const setCursorTheme =
48+
theme => () =>
49+
App.cursorTheme = theme
50+
51+
export const setGtkTheme =
52+
theme => () =>
53+
App.gtkTheme = theme
54+
1755
export const addWindow =
1856
window => () =>
1957
App.addWindow(window)

src/AGS/Service/App.purs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ foreign import data App ∷ Service
2828

2929
-- * Props
3030

31+
foreign import iconTheme Effect String
32+
foreign import cursorTheme Effect String
33+
foreign import gtkTheme Effect String
34+
foreign import configPath Effect String
3135
foreign import configDir Effect String
3236
foreign import windows Effect (Array Window)
3337

@@ -45,6 +49,12 @@ foreign import connectApp ∷ ∀ f. String → f → Effect (HandlerID App)
4549

4650
-- * Methods
4751

52+
foreign import addIcons String Effect Unit
53+
54+
foreign import setIconTheme String Effect Unit
55+
foreign import setCursorTheme String Effect Unit
56+
foreign import setGtkTheme String Effect Unit
57+
4858
foreign import addWindow Window Effect Unit
4959
foreign import removeWindow Window Effect Unit
5060

src/AGS/Service/Mpris.purs

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ module AGS.Service.Mpris
66
, BusName
77
, Player
88
, PlayerRecord
9+
, MprisMetadata
10+
, MprisMetadataF
911
, fromPlayer
1012
, playPause
1113
, play
@@ -25,7 +27,11 @@ import Data.Nullable (Nullable, toMaybe)
2527
import Effect (Effect)
2628
import Effect.Uncurried (EffectFn1, EffectFn2)
2729
import GObject (class GObjectSignal, HandlerID, unsafeConnect)
30+
import Record as R
31+
import Record.Studio.MapKind (mapRecordKind)
32+
import Type.Proxy (Proxy(..))
2833
import Unsafe.Coerce (unsafeCoerce)
34+
import Untagged.Union (UndefinedOr, uorToMaybe)
2935

3036
-- *** Mpris
3137

@@ -88,6 +94,7 @@ type PlayerRecord =
8894
, "cover-path"String
8995
, entry String
9096
, identity String
97+
, metadata MprisMetadata
9198
, length Int
9299
, "loop-status"Nullable Boolean
93100
, name String
@@ -97,17 +104,48 @@ type PlayerRecord =
97104
, "track-artists"Array String
98105
, "track-cover-url"String
99106
, "track-title"String
107+
, "track-album"String
100108
, trackid String
101109
, volume Int
102110
}
103111

104112
foreign import data PlayerType
105113

114+
type MprisMetadata = MprisMetadataF Maybe
115+
116+
type MprisMetadataF f =
117+
{ "mpris:trackid"f String
118+
, "mpris:length"f Number
119+
, "mpris:artUrl"f String
120+
, "xesam:album"f String
121+
, "xesam:albumArtist"f String
122+
, "xesam:artist"f (Array String)
123+
, "xesam:asText"f String
124+
, "xesam:audioBPM"f Number
125+
, "xesam:autoRating"f Number
126+
, "xesam:comment"f (Array String)
127+
, "xesam:composer"f (Array String)
128+
, "xesam:contentCreated"f String
129+
, "xesam:discNumber"f Number
130+
, "xesam:firstUsed"f String
131+
, "xesam:genre"f (Array String)
132+
, "xesam:lastUsed"f String
133+
, "xesam:lyricist"f (Array String)
134+
, "xesam:title"f String
135+
, "xesam:trackNumber"f Number
136+
, "xesam:url"f String
137+
, "xesam:useCount"f Number
138+
, "xesam:userRating"f Number
139+
}
140+
141+
fromForeignMetadata MprisMetadataF UndefinedOr MprisMetadata
142+
fromForeignMetadata = mapRecordKind uorToMaybe
143+
106144
-- * Props and bindings
107145

108146
-- | Convert a `Player` to a record.
109147
fromPlayer Player PlayerRecord
110-
fromPlayer = unsafeCoerce
148+
fromPlayer = R.modify (Proxy @"metadata") fromForeignMetadata <<< unsafeCoerce
111149

112150
-- the dbus name that starts with org.mpris.MediaPlayer2
113151
instance BindProp Player "bus-name" String where
@@ -131,6 +169,9 @@ instance BindProp Player "trackid" String where
131169
instance BindProp Player "track-artists" (Array String) where
132170
bindProp o = unsafeBindProp @"track-artists" o
133171

172+
instance BindProp Player "track-album" String where
173+
bindProp o = unsafeBindProp @"track-album" o
174+
134175
instance BindProp Player "track-title" String where
135176
bindProp o = unsafeBindProp @"track-title" o
136177

0 commit comments

Comments
 (0)