-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathi3_CapsNumLock.py
More file actions
executable file
·62 lines (50 loc) · 1.76 KB
/
i3_CapsNumLock.py
File metadata and controls
executable file
·62 lines (50 loc) · 1.76 KB
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
#!/usr/bin/env python3
#
# GNU GENERAL PUBLIC LICENSE v3
#
# Copyright (C) <2016> JOSE *MARCOS* <jm4rcos@gmail.com>
#
# This program is free software: you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free Software
# Foundation, either version 3 of the License, or (at your option) any later
# version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE.
#
# See <http://www.gnu.org/licenses/> for more details of the GNU General Public
# License.
#
# comments/requirements:
# Script designed to work with i3blocks to return CAPS and NUM status to i3bar.
#
# [*] key value for "markup" has to be "pango" in i3blocks config file.
import os
caps_onOff = ''
num_onOff = ''
color_on = ''
def is_caps_onOff():
# this function returns on/off status for Caps
caps_onOff = os.popen('xset q | grep -i caps | cut -c 22-24').read().strip()
return caps_onOff
def is_num_onOff():
# this function returns on/off status for Num
num_onOff = os.popen('xset q | grep -i caps | cut -c 46-48').read().strip()
return num_onOff
caps_onOff = is_caps_onOff()
num_onOff = is_num_onOff()
if caps_onOff == 'on':
C = "<span foreground=\"white\" background=\"gray\" \
font_weight=\"bold\"> C </span>"
else:
C = "<span font_weight=\"bold\"> C </span>"
if num_onOff == 'on':
N = "<span foreground=\"white\" background=\"gray\" \
font_weight=\"bold\"> N </span>"
else:
N = "<span font_weight=\"bold\"> N </span>"
# Print values as expected by i3blocks:
#
print (C + " | " + N)
print (C + " | " + N)