Advertisement
kikadf

Xsetup_0

Aug 15th, 2022
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.86 KB | Source Code | 0 0
  1. #!/bin/sh
  2. # $OpenBSD: Xsetup_0.in,v 1.1 2021/08/30 15:38:27 matthieu Exp $
  3.  
  4. xrandr --output default --dpi 96
  5. xbacklight -set 50
  6. xset b off
  7.  
  8. # requires pkg_add terminus-font
  9. xset fp+ /usr/local/share/fonts/terminus
  10.  
  11. XRES=$(xrdb -query)
  12.  
  13. # set background color
  14. BG_COLOR=$(echo "$XRES" | awk '/xroot.background/ { print $2 }')
  15. xsetroot -solid $BG_COLOR
  16.  
  17. # show the date and time as two different widgets
  18. for CLK in date time; do
  19.   FACE=$(echo "$XRES" | grep "xclock.${CLK}Face" | xargs | cut -d ' ' -f 2-)
  20.   GEOM=$(echo "$XRES" | grep "xclock.${CLK}Geom" | xargs | cut -d ' ' -f 2-)
  21.   STR=$(echo "$XRES"  | grep "xclock.${CLK}Str" | xargs | cut -d ' ' -f 2-)
  22.   xclock -face "$FACE" -geometry "$GEOM" -strftime "$STR" &
  23. done
  24.  
  25. # show the Sleep / Restart / Shutdown bar
  26. # in case of sleep, pop xmessage again after waking up
  27. (
  28. while true; do
  29.   xmessage -geometry -32-32 -buttons "[ Sleep ]":20,"[ Restart ]":21,"[ Shutdown ]":22 ""
  30.   ACTION=$?
  31.   echo "S/R/S bar: code $ACTION"
  32.   if   [ $ACTION -eq 20 ]; then
  33.     /usr/sbin/zzz;
  34.   elif [ $ACTION -eq 21 ]; then
  35.     xsetroot -cursor_name watch
  36.     /sbin/shutdown -r now
  37.   elif [ $ACTION -eq 22 ]; then
  38.     xsetroot -cursor_name watch
  39.     /sbin/shutdown -p now
  40.   else
  41.     echo "S/R/S bar: $ACTION is not a button code."
  42.   fi
  43.   # stop looping if xclock died (killed by GiveConsole)
  44.   if [ -z "$(pgrep -U root xclock)" ]; then break; fi
  45. done
  46. ) &
  47.  
  48. # session chooser bar
  49. (
  50. # get session list
  51. . /etc/X11/xenodm/session-list
  52. # set default session
  53. if [ ! -s /tmp/xenodm-session ]; then
  54.   echo "LXQt" > /tmp/xenodm-session
  55. fi
  56.  
  57. # make button list
  58. for _session in $SESSIONLIST; do
  59.   if [ -z $XBUTTONS ]; then
  60.     XBUTTONS="[ ${_session%_*} ]:${_session#*_}"
  61.   else
  62.     XBUTTONS="$XBUTTONS,[ ${_session%_*} ]:${_session#*_}"
  63.   fi
  64. done
  65.  
  66. # start bar
  67. while true; do
  68.   xmessage -geometry +32-32 -buttons "${XBUTTONS}" "Session: $(cat /tmp/xenodm-session)"
  69.   CACTION=$?
  70.   echo "Session Chooser: code $CACTION"
  71.   if [ $CACTION -ge 30 ] && [ $CACTION -le 39 ]; then
  72.     echo $SESSIONLIST | sed "s/_$CACTION.*//;s/.* //" > /tmp/xenodm-session
  73.   else
  74.     echo "Session Chooser: $CACTION is not a button code."
  75.   fi
  76.   # stop looping if xclock died (killed by GiveConsole)
  77.   if [ -z "$(pgrep -U root xclock)" ]; then break; fi
  78. done
  79. ) &
  80.  
  81. # uname
  82. (
  83. XUNAMES=$(uname -sr)
  84. XUNAMEA=$(uname -a)
  85. XUNAME=$XUNAMES
  86. while true; do
  87.   xmessage -geometry +32+2 -buttons "$XUNAME":0 ""
  88.   UACTION=$?
  89.   echo "Uname bar: code $UACTION"
  90.   if [ $UACTION -eq 0 ]; then
  91.     if [ "$XUNAME" = "$XUNAMES" ]; then
  92.       XUNAME=$XUNAMEA
  93.     else
  94.       XUNAME=$XUNAMES
  95.     fi
  96.   else
  97.     echo "Uname bar: $UACTION is not a button code."
  98.   fi
  99.   # stop looping if xclock died (killed by GiveConsole)
  100.   if [ -z "$(pgrep -U root xclock)" ]; then break; fi
  101. done
  102. ) &
  103.  
  104. # screenshot
  105. #sleep 3  && xwd -out /tmp/xenodm$(date +%Y%m%d.%H%M).xwd -root &
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement