Explorar el Código

Add separate info bar for clementine

Note that the bar is disabled by default; you will need to enable it
on-demand somwhow.  One possible way is wrapping clementine in a script
like this:

    i3-msg bar mode dock clementine
    /usr/bin/clementine
    i3-msg bar mode invisible clementine

However, due to i3 limitation, this will not guarrantee that the main
bar will always end up in the very bottom of the screen.  To work around
this:

    i3-msg bar mode dock clementine
    sleep 1
    i3-msg bar mode invisible main
    sleep 1
    i3-msg bar mode dock main
    /usr/bin/clementine
    i3-msg bar mode invisible clementine

Or vote for i3 feature request to make this more predictable:

    https://github.com/i3/i3/issues/2797
Alois Mahdal hace 7 años
padre
commit
48b0ccaa41
Se han modificado 2 ficheros con 90 adiciones y 0 borrados
  1. 79
    0
      dotfiles/i3/bin/cstatus
  2. 11
    0
      dotfiles/i3/config

+ 79
- 0
dotfiles/i3/bin/cstatus Ver fichero

@@ -0,0 +1,79 @@
1
+#!/bin/dash
2
+
3
+getpos() {
4
+    #
5
+    # Get track position
6
+    #
7
+    local h
8
+    local m
9
+    local s
10
+    s=$(qdbus org.mpris.clementine /Player org.freedesktop.MediaPlayer.PositionGet)
11
+    s=$((s/1000))
12
+    h=$((s/3600))
13
+    s=$((s%3600))
14
+    m=$((s/60))
15
+    s=$((s%60))
16
+    case $h in
17
+        0)  printf      '%d:%02d' $m $s ;;
18
+        *)  printf '%d:%02d:%02d' $h $m $s ;;
19
+    esac
20
+}
21
+
22
+mktext() {
23
+    #
24
+    # Compose info text from DBus
25
+    #
26
+    local artist
27
+    local year
28
+    local album
29
+    local tracknumber
30
+    local title
31
+    local sigil
32
+    local sigilcolor
33
+    local value
34
+    local key
35
+    local color_attr
36
+    qdbus org.mpris.clementine /Player org.freedesktop.MediaPlayer.GetMetadata >"$CACHE"
37
+    case $(qdbus org.mpris.clementine /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.PlaybackStatus) in
38
+        Stopped)    sigil=""; sigilcolor= ;;
39
+        Playing)    sigil=""; sigilcolor=green ;;
40
+        Paused)     sigil=""; sigilcolor=gray;;
41
+        *)          sigil=""; sigilcolor=red ;;
42
+    esac
43
+    test -n "$sigilcolor" && color_attr=" color='$sigilcolor'"
44
+    while read -r line; do
45
+        key=${line%%:*}
46
+        value=${line#$key: }
47
+        case $key in
48
+            artist)       artist=$value ;;
49
+            year)         year=$value ;;
50
+            album)        album=$value ;;
51
+            tracknumber)  tracknumber=$value ;;
52
+            title)        title=$value ;;
53
+        esac
54
+    done <"$CACHE"
55
+    printf "%s [%d %s]: %02d %s (%s) <span%s>%s</span>" \
56
+        "$artist" "$year" "$album" "$tracknumber" "$title" \
57
+        "$(getpos)" \
58
+        "$color_attr" "$sigil"
59
+}
60
+
61
+CACHE=$(mktemp -t cstatus.GetMetadata.XXXXXXXX)
62
+
63
+main() {
64
+    local head=true
65
+    echo '{"version":1}'
66
+    echo "["
67
+    while true; do
68
+        $head || echo -n ","
69
+        head=false
70
+        echo -n '[{'
71
+        echo -n '"markup":"pango",'
72
+        echo -n '"full_text":"'"$(mktext)"'"'
73
+        echo -n '}]'
74
+        echo
75
+        sleep 1
76
+    done
77
+}
78
+
79
+main

+ 11
- 0
dotfiles/i3/config Ver fichero

@@ -228,6 +228,17 @@ mode "resize" {
228 228
 }
229 229
 
230 230
 bar {
231
+    id clementine
232
+    status_command "~/.i3/bin/cstatus"
233
+    workspace_buttons no
234
+    tray_output none
235
+    mode hide
236
+    hidden_state hide
237
+    modifier none
238
+}
239
+
240
+bar {
241
+        id main
231 242
         status_command "~/.i3/bin/i3staplus"
232 243
         bindsym button2 exec thunar
233 244
         bindsym button3 exec "$spn xclose"