mirror of
https://github.com/vincentbernat/i3wm-configuration.git
synced 2025-07-10 10:14:20 +02:00
i3-companion: force font to use when using symbols
This commit is contained in:
parent
7669da1c9f
commit
9b5c00b92a
1 changed files with 53 additions and 28 deletions
|
@ -23,28 +23,43 @@ from systemd import journal
|
||||||
import ravel
|
import ravel
|
||||||
import dbussy
|
import dbussy
|
||||||
|
|
||||||
# See https://fontawesome.com/v6.0/icons
|
|
||||||
|
class Icon(str):
|
||||||
|
def __new__(cls, font, char):
|
||||||
|
return str.__new__(cls, "%%{T%s}%s%%{T-}" % (font, char))
|
||||||
|
|
||||||
|
|
||||||
|
# See https://fontawesome.com/v6.0/icons, number is the font number in
|
||||||
|
# polybar configuration.
|
||||||
application_icons = {
|
application_icons = {
|
||||||
"chromium": "",
|
"chromium": Icon(2, ""),
|
||||||
"discord": "",
|
"discord": Icon(2, ""),
|
||||||
"emacs": "",
|
"emacs": Icon(1, ""),
|
||||||
"firefox": "",
|
"firefox": Icon(2, ""),
|
||||||
"gimp": "",
|
"gimp": Icon(1, ""),
|
||||||
"gitg": "",
|
"gitg": Icon(1, ""),
|
||||||
"google-chrome": "",
|
"google-chrome": Icon(2, ""),
|
||||||
"inkscape": "",
|
"inkscape": Icon(1, ""),
|
||||||
"libreoffice": "",
|
"libreoffice": Icon(1, ""),
|
||||||
"mpv": "",
|
"mpv": Icon(1, ""),
|
||||||
"pavucontrol": "",
|
"pavucontrol": Icon(1, ""),
|
||||||
"signal": "",
|
"signal": Icon(1, ""),
|
||||||
"snes9x-gtk": "",
|
"snes9x-gtk": Icon(1, ""),
|
||||||
"spotify": "",
|
"spotify": Icon(2, ""),
|
||||||
"steam": "",
|
"steam": Icon(2, ""),
|
||||||
"vbeterm": "",
|
"vbeterm": Icon(1, ""),
|
||||||
"zathura": "",
|
"zathura": Icon(1, ""),
|
||||||
"zoom": "",
|
"zoom": Icon(1, ""),
|
||||||
}
|
}
|
||||||
application_icons_nomatch = ""
|
icons = {
|
||||||
|
"nowifi": Icon(1, ""),
|
||||||
|
"vpn": Icon(1, ""),
|
||||||
|
"wifi-low": Icon(1, ""),
|
||||||
|
"wifi-medium": Icon(1, ""),
|
||||||
|
"wifi-high": Icon(1, ""),
|
||||||
|
"wired": Icon(1, ""),
|
||||||
|
}
|
||||||
|
application_icons_nomatch = Icon(1, "")
|
||||||
application_icons_alone = {application_icons[k] for k in {"vbeterm"}}
|
application_icons_alone = {application_icons[k] for k in {"vbeterm"}}
|
||||||
exclusive_apps = {"emacs", "firefox"}
|
exclusive_apps = {"emacs", "firefox"}
|
||||||
intrusive_apps = {"vbeterm"}
|
intrusive_apps = {"vbeterm"}
|
||||||
|
@ -102,7 +117,7 @@ async def notify(i3, **kwargs):
|
||||||
return await notifications.Notify(**parameters)
|
return await notifications.Notify(**parameters)
|
||||||
|
|
||||||
|
|
||||||
@on(I3Event.WINDOW_MOVE, I3Event.WINDOW_NEW, I3Event.WINDOW_CLOSE)
|
@on(StartEvent, I3Event.WINDOW_MOVE, I3Event.WINDOW_NEW, I3Event.WINDOW_CLOSE)
|
||||||
async def workspace_rename(i3, event):
|
async def workspace_rename(i3, event):
|
||||||
"""Rename workspaces using icons to match what's inside it."""
|
"""Rename workspaces using icons to match what's inside it."""
|
||||||
tree = await i3.get_tree()
|
tree = await i3.get_tree()
|
||||||
|
@ -490,26 +505,36 @@ async def network_manager_status(i3, event, *args):
|
||||||
continue
|
continue
|
||||||
if kind == NM_DEVICE_TYPE_WIFI:
|
if kind == NM_DEVICE_TYPE_WIFI:
|
||||||
if state != NM_DEVICE_STATE_ACTIVATED:
|
if state != NM_DEVICE_STATE_ACTIVATED:
|
||||||
status.append("")
|
status.append(icons["nowifi"])
|
||||||
continue
|
continue
|
||||||
nmw = await bus[device].get_async_interface(
|
nmw = await bus[device].get_async_interface(
|
||||||
f"{ofnm}.Device.Wireless"
|
f"{ofnm}.Device.Wireless"
|
||||||
)
|
)
|
||||||
ap = await nmw.ActiveAccessPoint
|
ap = await nmw.ActiveAccessPoint
|
||||||
if not ap:
|
if not ap:
|
||||||
status.append("")
|
status.append(icons["nowifi"])
|
||||||
continue
|
continue
|
||||||
network_manager_status.active_ap = ap
|
network_manager_status.active_ap = ap
|
||||||
nmap = await bus[ap].get_async_interface(f"{ofnm}.AccessPoint")
|
nmap = await bus[ap].get_async_interface(f"{ofnm}.AccessPoint")
|
||||||
name = await nmap.Ssid
|
name = await nmap.Ssid
|
||||||
strength = int(await nmap.Strength)
|
strength = int(await nmap.Strength)
|
||||||
status.append(""[strength // 34])
|
status.append(
|
||||||
status.append(bytes(name).decode("utf-8", errors="replace"))
|
[
|
||||||
|
icons["wifi-low"],
|
||||||
|
icons["wifi-medium"],
|
||||||
|
icons["wifi-high"],
|
||||||
|
][strength // 34]
|
||||||
|
)
|
||||||
|
status.append(
|
||||||
|
bytes(name)
|
||||||
|
.decode("utf-8", errors="replace")
|
||||||
|
.replace("%", "%%")
|
||||||
|
)
|
||||||
elif (
|
elif (
|
||||||
kind == NM_DEVICE_TYPE_ETHERNET
|
kind == NM_DEVICE_TYPE_ETHERNET
|
||||||
and state == NM_DEVICE_STATE_ACTIVATED
|
and state == NM_DEVICE_STATE_ACTIVATED
|
||||||
):
|
):
|
||||||
status.append("")
|
status.append(icons["wired"])
|
||||||
|
|
||||||
# Build status for VPN connection
|
# Build status for VPN connection
|
||||||
connections = await nm.ActiveConnections
|
connections = await nm.ActiveConnections
|
||||||
|
@ -521,11 +546,11 @@ async def network_manager_status(i3, event, *args):
|
||||||
if vpn:
|
if vpn:
|
||||||
state = await nma.State
|
state = await nma.State
|
||||||
if state == NM_ACTIVE_CONNECTION_STATE_ACTIVATED:
|
if state == NM_ACTIVE_CONNECTION_STATE_ACTIVATED:
|
||||||
status.append("")
|
status.append("")
|
||||||
status.append(await nma.Id)
|
status.append(await nma.Id)
|
||||||
|
|
||||||
# Final status line
|
# Final status line
|
||||||
status = " ".join(status).replace("%", "%%")
|
status = " ".join(status)
|
||||||
last = getattr(network_manager_status, "last", None)
|
last = getattr(network_manager_status, "last", None)
|
||||||
|
|
||||||
if status != last:
|
if status != last:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue