From 3a801ba72de1be2d56c4c8c383c874a0d89ee66f Mon Sep 17 00:00:00 2001 From: 2Shirt <2xShirt@gmail.com> Date: Sat, 15 Sep 2018 15:08:47 -0600 Subject: [PATCH] Updated startup settings * Added support for HiDPI devices * Only affects devices with a DPI >= 192 * Most screen objects are doubled in size * Updated .conkyrc * Vertical offset now set to 24 or 48 (to match URxvt) * Removed extra line after network adapters * Updated .xinitrc * Removed dunst logic since `cbatticon` no longer sends notifications * Update .Xresources for all programs before `xrdb -merge` * Update hostname after `connect-to-network` * URxvt windows are now based on a 16:9 ratio (instead of 4:3) * Removed * .update_wallpaper (integrated with .xinitrc) * .urxvt_default_res (integrated with .update_dpi_settings) * Fixes issue #45 --- .../include/airootfs/etc/skel/.Xresources | 3 +- .../include/airootfs/etc/skel/.conkyrc | 9 ++- .../airootfs/etc/skel/.update_dpi_settings | 68 +++++++++++++++++++ .../airootfs/etc/skel/.update_hostname | 1 + .../airootfs/etc/skel/.update_wallpaper | 21 ------ .../airootfs/etc/skel/.urxvt_default_res | 10 --- .../include/airootfs/etc/skel/.wallpaper | 1 + .../include/airootfs/etc/skel/.xinitrc | 7 +- 8 files changed, 79 insertions(+), 41 deletions(-) create mode 100755 .linux_items/include/airootfs/etc/skel/.update_dpi_settings delete mode 100755 .linux_items/include/airootfs/etc/skel/.update_wallpaper delete mode 100755 .linux_items/include/airootfs/etc/skel/.urxvt_default_res create mode 120000 .linux_items/include/airootfs/etc/skel/.wallpaper diff --git a/.linux_items/include/airootfs/etc/skel/.Xresources b/.linux_items/include/airootfs/etc/skel/.Xresources index 68054af5..d659b735 100755 --- a/.linux_items/include/airootfs/etc/skel/.Xresources +++ b/.linux_items/include/airootfs/etc/skel/.Xresources @@ -21,7 +21,7 @@ URxvt*externalBorder: 0 !URxvt.colorIT: #87af5f !URxvt.colorBD: #c5c8c6 !URxvt.colorUL: #87afd7 -URxvt.geometry: 92x16 +URxvt.geometry: 92x16 URxvt.internalBorder: 8 URxvt.shading: 10 URxvt.transparent: true @@ -53,6 +53,7 @@ URxvt.transparent: true *.color15: #ffffff ! fonts +!Xft.dpi: 192 Xft.autohint: 0 Xft.antialias: 1 Xft.hinting: true diff --git a/.linux_items/include/airootfs/etc/skel/.conkyrc b/.linux_items/include/airootfs/etc/skel/.conkyrc index adfd5cbb..af09dd8f 100644 --- a/.linux_items/include/airootfs/etc/skel/.conkyrc +++ b/.linux_items/include/airootfs/etc/skel/.conkyrc @@ -37,7 +37,7 @@ minimum_size 180 0 ### width | height maximum_width 180 gap_x 20 ### left | right -gap_y 45 ### up | down +gap_y 24 ### up | down alignment tr ####################### End Window Settings ### @@ -143,15 +143,14 @@ Uptime:${alignr}${uptime_short} CPU: ${if_match ${cpu cpu0}<10} ${cpu cpu0}\ ${else}${if_match ${cpu cpu0}<100} ${cpu cpu0}\ ${else}${cpu cpu0}${endif}${endif}% Used${alignr}${freq_g} GHz -${cpugraph cpu0 20,180 ${color} ${color}} +${cpugraph cpu0 ${gap_x},${width} ${color} ${color}} RAM: ${mem} Used${alignr}${memmax} -${memgraph 20,180 ${color} ${color}} +${memgraph ${gap_x},${width} ${color} ${color}} Disk I/O: -${diskiograph 20,180 ${color} ${color}} +${diskiograph ${gap_x},${width} ${color} ${color}} Down: ${downspeed}${goto 115}Up:${alignr}${upspeed} #Network - ${alignc}S H O R T C U T K E Y S ${hr} [Super] + d${alignr}HW Diagnostics diff --git a/.linux_items/include/airootfs/etc/skel/.update_dpi_settings b/.linux_items/include/airootfs/etc/skel/.update_dpi_settings new file mode 100755 index 00000000..2287508c --- /dev/null +++ b/.linux_items/include/airootfs/etc/skel/.update_dpi_settings @@ -0,0 +1,68 @@ +#!/bin/env bash +# +## Calculate DPI and adjust display settings if necesary + +REGEX_XRANDR='^.* ([0-9]+)x([0-9]+)\+[0-9]+\+[0-9]+.* ([0-9]+)mm x ([0-9]+)mm.*$' +REGEX_URXVT='(URxvt.geometry:\s+).*' + +# Get screen data +xrandr_str="$(xrandr | grep mm | head -1)" +width_px="$(echo "${xrandr_str}" | sed -r "s/${REGEX_XRANDR}/\1/")" +height_px="$(echo "${xrandr_str}" | sed -r "s/${REGEX_XRANDR}/\2/")" +width_mm="$(echo "${xrandr_str}" | sed -r "s/${REGEX_XRANDR}/\3/")" +height_mm="$(echo "${xrandr_str}" | sed -r "s/${REGEX_XRANDR}/\4/")" + +# Convert to in +width_in="$(echo "${width_mm} * 0.03937" | bc)" +height_in="$(echo "${height_mm} * 0.03937" | bc)" + +# Calculate diagonals +diag_px="$(echo "sqrt(${width_px}^2 + ${height_px}^2)" | bc)" +diag_in="$(echo "sqrt(${width_in}^2 + ${height_in}^2)" | bc)" + +# Calculate DPI +dpi="$(echo "${diag_px} / ${diag_in}" | bc 2>/dev/null || True)" +dpi="${dpi:-0}" + +# Calculate URxvt default window size +width_urxvt="$(echo "${width_px} * 112/1280" | bc)" +height_urxvt="$(echo "${height_px} * 33/720" | bc)" +offset_urxvt="24" + +# Update settings if necessary +if [[ "${dpi}" -ge 192 ]]; then + # Conky + sed -i 's/minimum_size 180 0/minimum_size 360 0/' "${HOME}/.conkyrc" + sed -i 's/maximum_width 180/maximum_width 360/' "${HOME}/.conkyrc" + sed -i 's/gap_x 20/gap_x 40/' "${HOME}/.conkyrc" + sed -i 's/gap_y 24/gap_y 48/' "${HOME}/.conkyrc" + + # Fonts + sed -i 's/!Xft.dpi: 192/Xft.dpi: 192/' "${HOME}/.Xresources" + + # GDK + export GDK_SCALE=2 + export GDK_DPI_SCALE=0.5 + + # i3 + sed -i -r 's/(height\s+) 26/\1 52/' "${HOME}/.config/i3/config" + + # Tint2 + sed -i 's/panel_size = 100% 30/panel_size = 100% 60/' \ + "${HOME}/.config/tint2/tint2rc" + sed -i 's/Inconsolata 10/Inconsolata 20/g' \ + "${HOME}/.config/tint2/tint2rc" + sed -i 's/Inconsolata 12/Inconsolata 24/g' \ + "${HOME}/.config/tint2/tint2rc" + sed -i 's/systray_icon_size = 24/systray_icon_size = 48/' \ + "${HOME}/.config/tint2/tint2rc" + + # URxvt + width_urxvt="$(echo "${width_urxvt} / 2" | bc)" + height_urxvt="$(echo "${height_urxvt} / 2" | bc)" + offset_urxvt="$(echo "${offset_urxvt} * 2" | bc)" +fi + +# Update URxvt (Always) +urxvt_geometry="${width_urxvt}x${height_urxvt}+${offset_urxvt}+${offset_urxvt}" +sed -i -r "s/${REGEX_URXVT}/\1${urxvt_geometry}/" "${HOME}/.Xresources" diff --git a/.linux_items/include/airootfs/etc/skel/.update_hostname b/.linux_items/include/airootfs/etc/skel/.update_hostname index da563ab6..3c1bd7c2 100755 --- a/.linux_items/include/airootfs/etc/skel/.update_hostname +++ b/.linux_items/include/airootfs/etc/skel/.update_hostname @@ -5,6 +5,7 @@ IP="$(ip a show scope global \ | head -1 \ | sed -r 's#.*inet ([0-9]+.[0-9]+.[0-9]+.[0-9]+.)/.*#\1#')" HOSTNAME="$(dig +noall +answer +short -x "$IP" \ + | head -1 \ | sed 's/\.$//')" # Set hostname and renew DHCP lease diff --git a/.linux_items/include/airootfs/etc/skel/.update_wallpaper b/.linux_items/include/airootfs/etc/skel/.update_wallpaper deleted file mode 100755 index 7bffa12b..00000000 --- a/.linux_items/include/airootfs/etc/skel/.update_wallpaper +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/bash - -BOOT_PATH="/run/archiso/bootmnt/arch/" -BURNED_IN="/usr/share/wallpaper/burned.in" -WALLPAPER="$HOME/.wallpaper.png" - -function link_wall() { - sudo rm "$WALLPAPER" - sudo ln -s "$1" "$WALLPAPER" -} - -# Check for wallpaper -## Checks BOOT_PATH and uses the BURNED_IN file if nothing is found -for f in "$BOOT_PATH"/{Arch,arch}.{jpg,png} "$BURNED_IN"; do - if [[ -f "$f" ]]; then - link_wall "$f" - break - fi -done - -feh --bg-fill "$WALLPAPER" diff --git a/.linux_items/include/airootfs/etc/skel/.urxvt_default_res b/.linux_items/include/airootfs/etc/skel/.urxvt_default_res deleted file mode 100755 index 1e146090..00000000 --- a/.linux_items/include/airootfs/etc/skel/.urxvt_default_res +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash - -XWIDTH="$(xrandr 2>/dev/null | grep '*' | sed -r 's/^\s+([0-9]+)x.*/\1/')" -XHEIGHT="$(xrandr 2>/dev/null | grep '*' | sed -r 's/^\s+[0-9]+x([0-9]+).*/\1/')" - -WIDTH="$(echo "${XWIDTH}*92/1024" | bc)" -HEIGHT="$(echo "${XHEIGHT}*32/768" | bc)" - -sed -i -r "s/(URxvt.geometry:\s+).*/\1${WIDTH}x${HEIGHT}+24+24/" ~/.Xresources -xrdb -merge ~/.Xresources diff --git a/.linux_items/include/airootfs/etc/skel/.wallpaper b/.linux_items/include/airootfs/etc/skel/.wallpaper new file mode 120000 index 00000000..f2a3d5e1 --- /dev/null +++ b/.linux_items/include/airootfs/etc/skel/.wallpaper @@ -0,0 +1 @@ +/usr/share/wallpaper/burned.in \ No newline at end of file diff --git a/.linux_items/include/airootfs/etc/skel/.xinitrc b/.linux_items/include/airootfs/etc/skel/.xinitrc index ddc70863..abb71f45 100755 --- a/.linux_items/include/airootfs/etc/skel/.xinitrc +++ b/.linux_items/include/airootfs/etc/skel/.xinitrc @@ -1,6 +1,7 @@ #!/bin/sh dbus-update-activation-environment --systemd DISPLAY +$HOME/.update_dpi_settings xrdb -merge $HOME/.Xresources xset s off xset -dpms @@ -11,10 +12,8 @@ sleep 1s conky -d nm-applet & volumeicon & -$HOME/.update_hostname connect-to-network & -(sleep 5s && killall dunst) & -$HOME/.urxvt_default_res & -$HOME/.update_wallpaper & +$HOME/.update_hostname & +feh --bg-fill "$HOME/.wallpaper" & x0vncserver -display :0 -passwordfile $HOME/.vnc/passwd -AlwaysShared & exec openbox-session