How's everyone doing?
So, if I run xdotool getactivewindow getwindowname, it gives the full title of the current window, for example:
fish home/kibe/Documents — Konsole
Blablablabla - Stack Overflow - Google Chrome
The thing is, I only want the application name (Konsole and Google Chrome).
I can easily do it in Python, as such:
def getAppTitle (fullStr):
lastDashIndex = None
for i in range(len(fullStr)):
if fullStr[i] == '-' or fullStr[i] == '—':
lastDashIndex = i
return fullStr[lastDashIndex+2:] if lastDashIndex else fullStr
print(getAppTitle('blablabla - blablabla - ApplicationName'))
# returns ApplicationName
I have been trying to do the same in shell script but I can't do it for the life of me. Also, for some reasons, some applications use "-" (normal dash) and others "—" (em dash).
How can I do that in shell?