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
This commit is contained in:
2Shirt 2018-09-15 15:08:47 -06:00
parent cdef33d774
commit 3a801ba72d
Signed by: 2Shirt
GPG key ID: 152FAC923B0E132C
8 changed files with 79 additions and 41 deletions

View file

@ -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

View file

@ -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

View file

@ -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"

View file

@ -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

View file

@ -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"

View file

@ -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

View file

@ -0,0 +1 @@
/usr/share/wallpaper/burned.in

View file

@ -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