better cursor support

This commit is contained in:
Linus Dierheimer
2021-06-26 11:39:42 +02:00
parent d4d9bc90e6
commit a88cb07dad
4 changed files with 111 additions and 7 deletions
+1 -1
View File
@@ -1 +1 @@
--structure OS:Kernel:Shell:DE:WM:WMTheme:Theme:Icons:Font:Terminal:TerminalFont
--structure OS:Kernel:Shell:DE:WM:WMTheme:Theme:Icons:Font:Cursor:Terminal:TerminalFont
+5 -2
View File
@@ -67,15 +67,18 @@ static void detectGTKFromDConf(FFinstance* instance, FFGTKResult* result)
themeName = ffSettingsGet(instance, "/org/mate/interface/gtk-theme", "org.mate.interface", NULL, "gtk-theme", FF_VARIANT_TYPE_STRING).strValue;
iconsName = ffSettingsGet(instance, "/org/mate/interface/icon-theme", "org.mate.interface", NULL, "icon-theme", FF_VARIANT_TYPE_STRING).strValue;
fontName = ffSettingsGet(instance, "/org/mate/interface/font-name", "org.mate.interface", NULL, "font-name", FF_VARIANT_TYPE_STRING).strValue;
cursorTheme = ffSettingsGet(instance, "/org/mate/interface/cursor-theme", "org.mate.interface", NULL, "cursor-theme", FF_VARIANT_TYPE_STRING).strValue;
cursorSize = ffSettingsGet(instance, "/org/mate/interface/cursor-size", "org.mate.interface", NULL, "cursor-size", FF_VARIANT_TYPE_INT).intValue;
cursorTheme = ffSettingsGet(instance, "/org/mate/peripherals-mouse/cursor-theme", "org.mate.peripherals-mouse", NULL, "cursor-theme", FF_VARIANT_TYPE_STRING).strValue;
cursorSize = ffSettingsGet(instance, "/org/mate/peripherals-mouse/cursor-size", "org.mate.peripherals-mouse", NULL, "cursor-size", FF_VARIANT_TYPE_INT).intValue;
}
//Fallback + Gnome impl
if(themeName == NULL)
themeName = ffSettingsGet(instance, "/org/gnome/desktop/interface/gtk-theme", "org.gnome.desktop.interface", NULL, "gtk-theme", FF_VARIANT_TYPE_STRING).strValue;
if(iconsName == NULL)
iconsName = ffSettingsGet(instance, "/org/gnome/desktop/interface/icon-theme", "org.gnome.desktop.interface", NULL, "icon-theme", FF_VARIANT_TYPE_STRING).strValue;
if(fontName == NULL)
fontName = ffSettingsGet(instance, "/org/gnome/desktop/interface/font-name", "org.gnome.desktop.interface", NULL, "font-name", FF_VARIANT_TYPE_STRING).strValue;
+6 -1
View File
@@ -57,12 +57,17 @@ static void printBattery(FFinstance* instance, FFstrbuf* dir, uint32_t index)
putchar('%');
if(showStatus)
fputs("; ", stdout);
fputs(" [", stdout);
}
if(showStatus)
{
ffStrbufWriteTo(&status, stdout);
if(capacity.length > 0)
putchar(']');
}
putchar('\n');
}
else
+99 -3
View File
@@ -8,7 +8,7 @@ static void printCursor(FFinstance* instance, const FFstrbuf* cursorTheme, const
ffPrintLogoAndKey(instance, FF_CURSOR_MODULE_NAME, 0, &instance->config.cursorKey);
ffStrbufWriteTo(cursorTheme, stdout);
if(cursorSize->length > 0)
if(cursorSize != NULL && cursorSize->length > 0)
{
fputs(" (", stdout);
ffStrbufWriteTo(cursorSize, stdout);
@@ -91,14 +91,110 @@ static void printCursorXFCE(FFinstance* instance)
ffStrbufDestroy(&cursorSize);
}
static bool printCursorFromXResources(FFinstance* instance)
{
FFstrbuf theme;
ffStrbufInit(&theme);
FFstrbuf size;
ffStrbufInit(&size);
ffParsePropFileHomeValues(instance, ".Xresources", 2, (FFpropquery[]) {
{"Xcursor.theme :", &theme},
{"Xcursor.size :", &size}
});
if(theme.length == 0)
{
ffStrbufDestroy(&size);
ffStrbufDestroy(&theme);
return false;
}
printCursor(instance, &theme, &size);
ffStrbufDestroy(&size);
ffStrbufDestroy(&theme);
return true;
}
static bool printCursorFromXDG(FFinstance* instance, bool user)
{
FFstrbuf theme;
ffStrbufInit(&theme);
if(user)
ffParsePropFileHome(instance, ".icons/default/index.theme", "Inherits =", &theme);
else
ffParsePropFile("/usr/share/icons/default/index.theme", "Inherits =", &theme);
if(theme.length == 0)
{
ffStrbufDestroy(&theme);
return false;
}
printCursor(instance, &theme, NULL);
ffStrbufDestroy(&theme);
return true;
}
static bool printCursorFromEnv(FFinstance* instance)
{
const char* xcursor_theme = getenv("XCURSOR_THEME");
if(xcursor_theme == NULL || *xcursor_theme == '\0')
return false;
FFstrbuf theme;
ffStrbufInit(&theme);
ffStrbufAppendS(&theme, xcursor_theme);
FFstrbuf size;
ffStrbufInit(&size);
ffStrbufAppendS(&size, getenv("XCURSOR_SIZE"));
printCursor(instance, &theme, &size);
ffStrbufDestroy(&size);
ffStrbufDestroy(&theme);
return true;
}
void ffPrintCursor(FFinstance* instance)
{
if(printCursorFromEnv(instance))
return;
const FFWMDEResult* wmde = ffDetectWMDE(instance);
if(ffStrbufIgnCaseCompS(&wmde->dePrettyName, "KDE Plasma") == 0)
{
printCursorPlasma(instance);
else if(ffStrbufStartsWithIgnCaseS(&wmde->dePrettyName, "XFCE"))
return;
}
if(ffStrbufStartsWithIgnCaseS(&wmde->dePrettyName, "XFCE"))
{
printCursorXFCE(instance);
else
return;
}
if(ffStrbufIgnCaseCompS(&wmde->dePrettyName, "Gnome") == 0 || ffStrbufIgnCaseCompS(&wmde->dePrettyName, "Cinnamon") == 0 || ffStrbufIgnCaseCompS(&wmde->dePrettyName, "Mate") == 0)
{
printCursorGTK(instance);
return;
}
//User config
if(printCursorFromXDG(instance, true))
return;
if(printCursorFromXResources(instance))
return;
//System config
if(printCursorFromXDG(instance, false))
return;
printCursorGTK(instance);
}