📜 ⬆️ ⬇️

Thinstation session selection menu

In the second version of Thinstation there was a session selection menu at boot time - Replimenu . Although it was ugly and sometimes it drove into a stupor an unprepared user who was used to a full-fledged graphics mode, but it worked. In the fifth version, it “broke down”, and the developers didn’t screw any replacement, to the question “Where did the menu go?” Answered:
If you’re not in the first place, you’re not 10 years and are no longer on the support radar.
what in free translation means - such computers, so that very little memory, for 10 years they don’t produce, use a window manager with icons on the desktop.
I was not satisfied with such an approach to solving the problem, and therefore I decided to create my own menu for session selection, since the Thinstation functionality allows it.

From the run-up, to implement a full-fledged replacement, so that any session option from the configuration file would automatically hook up, did not work, and there was no such task. It was necessary to give the user the choice of connecting to one of the three terminal servers on Windows.

To display the menu, we will use the Zenity utility, which displays dialog boxes from the command line and shell scripts.
')
Create folders and package files, I called it xmenu , copy the cursor and font into it:
cd ///thinstation/ts/build/packages mkdir -p xmenu/{etc/{init.d,rc5.d},bin,lib/{fonts/X11/TTF,icons/default/cursors}} cp icons-cursor/lib/icons/dmz-aa/cursors/top_left_arrow xmenu/lib/icons/default/cursors cp fonts-TTF-liberation/lib/fonts/X11/TTF/LiberationMono-Regular.ttf xmenu/lib/fonts/X11/TTF echo -e "base\nzenity\npango\nfontconfig" > xmenu/dependencies echo ",dependencies,0,0,,0,,,,,,,,," > xmenu/.dna echo > xmenu/bin/xmenu echo > xmenu/etc/init.d/xmenu chmod 766 xmenu/bin/xmenu chmod 766 xmenu/etc/init.d/xmenu cd xmenu/etc/rc5.d ln -s ../init.d/xmenu xmenu 

Copy the initialization script to xmenu / etc / init.d / xmenu :
 #! /bin/sh . $TS_GLOBAL case "$1" in init) if ! pkg_initialized $PACKAGE; then pkg_set_init_flag $PACKAGE fi ;; console) exec /bin/xmenu ;; help) echo "Usage: $0 {init|console}" ;; *) exit 1 ;; esac exit 0 

In xmenu / bin / xmenu, copy the menu script itself:
 #!/bin/sh . $TS_GLOBAL # IP  IPSHOW=$(ifconfig | grep 'inet addr:'| grep -v '127.0.0.1' | cut -d: -f2 | awk '{ print $1}') #     xsetroot -cursor_name top_left_arrow -solid rgb:4B/69/83 #Menu zenity: ip=`zenity --list --timeout=30 --height=250 --print-column=1,2 --hide-column=1,2 \ --text=": $(hostname) ||| IP: $IPSHOW""\n"'<span foreground="blue">\ \n    [Cancel]\n\       [OK]\n\ </span>' --column "type" --column "server" --column " :" \ "$MENU_1_TYPE" "$MENU_1_SERVER" "$MENU_1_TITLE" \ "$MENU_2_TYPE" "$MENU_2_SERVER" "$MENU_2_TITLE" \ "$MENU_3_TYPE" "$MENU_3_SERVER" "$MENU_3_TITLE"` retval=$? #     : case $retval in 0) # IP : ipserver=$(echo $ip | awk -F'|' '{ print $2 }') #   rdesktop   , : if echo $ip | grep rdesktop && echo $ip | grep -u ; then rdesktop $RDESKTOP_OPTIONS $ipserver #   rdesktop  , : elif echo $ip | grep rdesktop; then rdesktop -u '' $RDESKTOP_OPTIONS $ipserver #   freerdp, : elif echo $ip | grep freerdp; then xfreerdp $FREERDP_OPTIONS /v:$ipserver #       ,   : else zenity --warning --text="   .\n \   ..." xmenu fi;; #   [Cancel]  Esc  ,   : 1|5|-1) poweroff;; esac exit 0 

This script is suitable for running freerdp and rdesktop sessions, after 30 seconds of inactivity (parameter --timeout = 30 ) the computer will turn off.

The menu package is ready, we include it into the build with the line package xmenu in the build.conf.example file and build the image.

In thinstation.conf.xxx, you need to REPLACE session variables with:
 #   ,   SESSION_0_TYPE=xmenu SESSION_0_AUTOSTART=On #  ,   : RDESKTOP_OPTIONS="-x 0x90 -N -a 16 -f -k ru -x l" FREERDP_OPTIONS="+fonts -sec-tls -sec-nla" #   ,    IP  MENU_1_TITLE="1" MENU_1_TYPE=rdesktop MENU_1_SERVER=192.168.111.100 MENU_2_TITLE="2" MENU_2_TYPE=freerdp MENU_2_SERVER=192.168.111.100 MENU_3_TITLE="3" MENU_3_TYPE=freerdp MENU_3_SERVER=192.168.111.100 

After loading the image, we’ll see such a nice menu:

image

In my opinion it is much nicer than replimenu, everything is in Russian and users with a mouse are more comfortable to manage. When you click the " Cancel " button in the menu or Esc on the keyboard, the thin client will turn off.

If users don’t see the menu items, you can increase the font size in the packages / fontconfig / etc / fonts / conf.avail / 51-local.conf file , bringing it to this look and changing the pixelsize parameter:
 <?xml version="1.0"?> <!DOCTYPE fontconfig SYSTEM "fonts.dtd"> <fontconfig> <!-- Load local system customization file --> <match target="font"> <edit name="pixelsize" mode="assign"><int>22</int></edit> </match> <include ignore_missing="yes">local.conf</include> </fontconfig> 
Get this menu:

image

If the config download is configured over the network and the server names in the menu should be written in Russian (Cyrillic), then in the packages / netfiles / etc / init.d / network_files file , at the beginning there are 34 lines
 catv /tmp/"$CONFNET"network |sed -e 's/\^M//g' >> $TS_NETWORK 2> /dev/null 
replace catv with cat , otherwise in the menu you will get kryakozyabry.
In principle, you can replace catv with cat in the whole file, it won't be worse.

Source: https://habr.com/ru/post/268697/


All Articles