Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Q
qbar
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD 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
jktr
qbar
Commits
d5f18388
Commit
d5f18388
authored
5 years ago
by
Jens Nolte
Browse files
Options
Downloads
Patches
Plain Diff
Fix render indicator by moving it to the end of the pipeline
parent
eb0294f5
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/QBar/Server.hs
+16
-14
16 additions, 14 deletions
src/QBar/Server.hs
src/QBar/Theme.hs
+13
-2
13 additions, 2 deletions
src/QBar/Theme.hs
with
29 additions
and
16 deletions
src/QBar/Server.hs
+
16
−
14
View file @
d5f18388
...
...
@@ -12,7 +12,7 @@ import QBar.Pango
import
QBar.Theme
import
QBar.Util
import
Control.Monad
(
forever
,
when
,
unless
,
forM_
)
import
Control.Monad
(
when
,
unless
,
forM_
)
import
Control.Concurrent.Async
(
async
,
link
)
import
Control.Concurrent.Event
as
Event
import
Control.Concurrent.MVar
(
MVar
,
newMVar
,
modifyMVar
,
modifyMVar_
)
...
...
@@ -29,9 +29,8 @@ import Pipes.Concurrent (Input, spawn, latest, toOutput, fromInput)
import
qualified
Pipes.Prelude
as
PP
import
System.IO
(
stdin
,
stdout
,
stderr
,
hFlush
)
renderIndicator
::
CachedBlock
-- Using 'cachedBlock' is a hack to actually get the block to update on every bar update (by doing this it will not get a cache later in the pipeline).
renderIndicator
=
forever
$
each
$
map
(
mkBlockState
.
mkBlockOutput
.
normalText
)
[
"/"
,
"-"
,
"
\\
"
,
"|"
]
renderIndicators
::
[
Text
]
renderIndicators
=
[
"*"
]
<>
cycle
[
"/"
,
"-"
,
"
\\
"
,
"|"
]
data
PangoBlock
=
PangoBlock
{
pangoBlockFullText
::
PangoText
,
...
...
@@ -75,18 +74,27 @@ swayBarInput MainOptions{verbose} = swayBarInput'
swayBarOutput
::
MainOptions
->
Consumer
[
ThemedBlockOutput
]
IO
()
swayBarOutput
options
=
do
swayBarOutput
options
@
MainOptions
{
indicator
}
=
do
-- Print header
liftIO
$
do
putStrLn
"{
\"
version
\"
:1,
\"
click_events
\"
:true}"
putStrLn
"["
swayBarOutput'
if
indicator
then
swayBarOutputWithIndicator'
renderIndicators
else
swayBarOutput'
where
swayBarOutput'
::
Consumer
[
ThemedBlockOutput
]
IO
()
swayBarOutput'
=
do
await
>>=
(
liftIO
.
outputLine
options
)
blockOutputs
<-
await
liftIO
$
outputLine
options
blockOutputs
swayBarOutput'
swayBarOutputWithIndicator'
::
[
Text
]
->
Consumer
[
ThemedBlockOutput
]
IO
()
swayBarOutputWithIndicator'
[]
=
throw
$
userError
"List should be infinite"
swayBarOutputWithIndicator'
(
ind
:
inds
)
=
do
blockOutputs
<-
await
liftIO
$
outputLine
options
(
blockOutputs
<>
[
whiteThemedBlockOutput
ind
])
swayBarOutputWithIndicator'
inds
outputLine
::
MainOptions
->
[
ThemedBlockOutput
]
->
IO
()
outputLine
MainOptions
{
verbose
}
themedBlocks
=
do
let
encodedOutput
=
encodeOutput
themedBlocks
...
...
@@ -110,14 +118,8 @@ swayBarOutput options = do
}
runBarServer
::
BarIO
()
->
MainOptions
->
IO
()
runBarServer
defaultBarConfig
options
=
runBarHost
barServer
(
swayBarInput
options
)
loadBlocks
runBarServer
defaultBarConfig
options
=
runBarHost
barServer
(
swayBarInput
options
)
defaultBarConfig
where
loadBlocks
::
BarIO
()
loadBlocks
=
do
-- Load blocks
when
(
indicator
options
)
$
addBlock
renderIndicator
defaultBarConfig
barServer
::
Consumer
[
BlockOutput
]
IO
()
barServer
=
do
-- Event to render the bar (fired when block output or theme is changed)
...
...
This diff is collapsed.
Click to expand it.
src/QBar/Theme.hs
+
13
−
2
View file @
d5f18388
...
...
@@ -69,7 +69,6 @@ findTheme themeName = maybe invalidThemeName Right $ HM.lookup themeName themes
where
invalidThemeName
=
Left
$
"Invalid theme: "
<>
themeName
mkTheme
::
SimplifiedTheme
->
Theme
mkTheme
theming'
=
StaticTheme
$
map
themeBlock
where
...
...
@@ -89,9 +88,22 @@ mkTheme theming' = StaticTheme $ map themeBlock
themeSegment
::
SimplifiedTheme
->
BlockTextSegment
->
ThemedBlockTextSegment
themeSegment
theming
BlockTextSegment
{
active
,
importance
,
segmentText
}
=
mkThemedSegment
(
theming
active
importance
)
segmentText
mkThemedBlockOutput
::
(
Color
,
Maybe
Color
)
->
Text
->
ThemedBlockOutput
mkThemedBlockOutput
color
text
=
ThemedBlockOutput
{
_fullText
=
mkThemedText
color
text
,
_shortText
=
Nothing
,
_blockName
=
Nothing
}
mkThemedText
::
(
Color
,
Maybe
Color
)
->
Text
->
ThemedBlockText
mkThemedText
color
text
=
ThemedBlockText
[
mkThemedSegment
color
text
]
mkThemedSegment
::
(
Color
,
Maybe
Color
)
->
Text
->
ThemedBlockTextSegment
mkThemedSegment
(
color
,
backgroundColor
)
text
=
ThemedBlockTextSegment
{
themedSegmentText
=
text
,
color
,
backgroundColor
}
whiteThemedBlockOutput
::
Text
->
ThemedBlockOutput
whiteThemedBlockOutput
=
mkThemedBlockOutput
(
ColorRGB
(
RGB
1
1
1
),
Nothing
)
invalidColor
::
Color
invalidColor
=
ColorRGBA
(
RGB
(
0x96
/
255
)
(
0x98
/
255
)
(
0x96
/
255
))
(
0x77
/
255
)
...
...
@@ -151,4 +163,3 @@ rainbowTheme = AnimatedTheme rainbowThemePipe
let
hue'
=
position
*
3
color
=
hsv
hue'
0.8
1.0
in
ColorRGB
color
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