From 076d00e65ffec02be2c881d91900cd1d1a4f7ee8 Mon Sep 17 00:00:00 2001 From: Donovan Glover Date: Fri, 23 Nov 2018 14:34:19 -0500 Subject: [PATCH] rofi: Scale windows pragmatically with launch.sh Instead of manually setting the DPI to 192 or other values, we can just take the value from xrdb instead. This script, in combination with GTK's settings.ini if you are in a non-GNOME environment, is everything you need to launch both GTK and Qt applications at the appropriate DPI, with their respective themes applied as well. --- rofi/.config/rofi/config.rasi | 1 - rofi/.config/rofi/launch.sh | 27 +++++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) create mode 100755 rofi/.config/rofi/launch.sh diff --git a/rofi/.config/rofi/config.rasi b/rofi/.config/rofi/config.rasi index 8cc77f8..87fd1fc 100644 --- a/rofi/.config/rofi/config.rasi +++ b/rofi/.config/rofi/config.rasi @@ -1,6 +1,5 @@ configuration { modi: "window,run,drun"; - dpi: 192; font: "Hack 12"; show-icons: true; bw: 0; diff --git a/rofi/.config/rofi/launch.sh b/rofi/.config/rofi/launch.sh new file mode 100755 index 0000000..f4655a2 --- /dev/null +++ b/rofi/.config/rofi/launch.sh @@ -0,0 +1,27 @@ +#!/bin/sh +# New Start: A modern Arch workflow built with an emphasis on functionality. +# Copyright (C) 2018 Donovan Glover + +# This script will find the X server DPI and apply the necessary +# settings to make Rofi, X, GNOME, and KDE applications have the +# proper scaling, with no intervention from the user necessary. + +# Note that XDG_CURRENT_DESKTOP is required for KDE/Qt applications to +# have the proper theming in non-Plasma environments. In contrast, GNOME +# respects its theming even when XDG_CURRENT_DESKTOP is not set to it +# (through settings.ini). + +ROFI_DPI=$(xrdb -query | grep Xft.dpi | cut -f 2) +ROFI_SCALE=$(expr $ROFI_DPI / 96) +ROFI_DPI_SCALE=$(awk "BEGIN { print "1/$ROFI_SCALE" }") + +env \ + XDG_CURRENT_DESKTOP="KDE" \ + QT_AUTO_SCREEN_SCALE_FACTOR="0" \ + QT_FONT_DPI="$ROFI_DPI" \ + QT_SCREEN_SCALE_FACTORS="VGA-1=$ROFI_SCALE;" \ + GDK_SCALE="$ROFI_SCALE" \ + GDK_DPI_SCALE="$ROFI_DPI_SCALE" \ + rofi \ + -show drun \ + -dpi "$ROFI_DPI"