-
Notifications
You must be signed in to change notification settings - Fork 5
/
focused-window.coffee
117 lines (92 loc) · 4.34 KB
/
focused-window.coffee
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#
# ──────────────────────────────────────────────────────────────────── III ─────
# :::::: F O C U S E D W I N D O W : : : : : : : :
# ──────────────────────────────────────────────────────────────────────────────
#
#
# ─── CONSTANTS ──────────────────────────────────────────────────────────────
#
MAX_LENGTH = 40
#
# ─── ALL COMMANDS ───────────────────────────────────────────────────────────
#
commands =
owner: "/usr/local/bin/chunkc tiling::query --window owner"
name: "/usr/local/bin/chunkc tiling::query --window name"
#
# ─── GLOBALS ────────────────────────────────────────────────────────────────
#
globals =
owner: ""
name: ""
#
# ─── COLORS ─────────────────────────────────────────────────────────────────
#
colors =
black: "#1d2021"
grey: "#a89984"
red: "#fb4924"
green: "#b8bb26"
yellow: "#fabd2f"
blue: "#458588"
magenta: "#b16286"
cyan: "#689d6a"
white: "#ebdbb2"
#
# ─── COMMAND ────────────────────────────────────────────────────────────────
#
command: "echo " +
"$(#{ commands.owner }):::" +
"$(#{ commands.name })"
#
# ─── REFRESH ────────────────────────────────────────────────────────────────
#
refreshFrequency: 1000
#
# ─── RENDER ─────────────────────────────────────────────────────────────────
#
render: ( ) ->
"""
<link rel="stylesheet" href="./font-awesome/font-awesome.min.css" />
<div class="info-item window">
<div class="icon"><i class="fa fa-window-maximize"></i></div>
<span class="window-output"></span>
</div>
"""
#
# ─── RENDER ─────────────────────────────────────────────────────────────────
#
update: ( output ) ->
output = output.split( /:::/g )
owner = output[ 0 ]
name = output[ 1 ]
if owner.replace( /([ \t\n])/g, "" ).length > 0
globals.owner = owner
if name.replace( /([ \t\n])/g, "" ).length > 0
if name.length > MAX_LENGTH
globals.name = name.substr(0, 40) + "..."
else
globals.name = name
$( ".window-output" ).text( "#{ globals.owner } - #{ globals.name }" )
#
# ─── STYLE ──────────────────────────────────────────────────────────────────
#
style: """
.window .icon
background-color: #{ colors.blue }
.info-item
display: flex
padding: 0px 5px 0 0
background-color: #{ colors.white }
margin-left: 15px
.icon
padding: 1px 5px
margin-right: 5px
top: 3.5px
left: 0px
font-family: 'Fira Code'
font-size: 13px
font-smoothing: antialiasing
z-index: 0
"""
# ──────────────────────────────────────────────────────────────────────────────