![]() |
#1 |
Member
![]() Posts: 13
Karma: 10
Join Date: Jan 2025
Device: Kobo Libra 2
|
Dynamic NickelMenu labels
I've created a NickelMenu config that has a dynamic label for starting/stopping the FTP or Telnet server, and for turning the backlight off and on. It shows "FTP Start" when clicking it will start the FTP server, and "FTP Stop" when clicking it will stop the currently running FTP server.
Code:
## Do not change the comments right before the menu items ## The `sed` command uses it for finding the config line ## filename is assumed to be "config" ## if you change it the `sed` commands need to be updated # ## Main Menu # # ## Telnet Toggle menu_item : main : Telnet Start : cmd_output : 500:quiet :/usr/bin/pkill -f "^/usr/bin/tcpsvd -E 0.0.0.0 2023" chain_success:skip:11 chain_failure : cmd_spawn : quiet :/bin/mount -t devpts | /bin/grep -q /dev/pts || { /bin/mkdir -p /dev/pts && /bin/mount -t devpts devpts /dev/pts; } chain_success:skip:2 chain_failure : dbg_toast : Error starting Telnet server on port 2023 chain_success:skip:-1 chain_success : cmd_spawn : quiet :exec /usr/bin/tcpsvd -E 0.0.0.0 2023 /usr/sbin/telnetd -i -l /bin/login chain_success : cmd_output : 500:quiet :grep -x 'ForceWifiOn=true' '/mnt/onboard/.kobo/Kobo/Kobo eReader.conf' chain_failure : nickel_setting : enable : force_wifi chain_success : nickel_wifi : autoconnect_silent chain_success : dbg_toast : Started Telnet server on port 2023 chain_success : cmd_spawn : quiet :sed -i '/^## Telnet Toggle/ { n; s/^\([^:]*:[^:]*:\)[^:]*\(:.*\)$/\1 Telnet Stop \2/ }' /mnt/onboard/.adds/nm/config chain_always:skip:-1 chain_success : dbg_toast : Stopped Telnet server on port 2023 chain_success : cmd_spawn : quiet :sed -i '/^## Telnet Toggle/ { n; s/^\([^:]*:[^:]*:\)[^:]*\(:.*\)$/\1 Telnet Start \2/ }' /mnt/onboard/.adds/nm/config chain_success : cmd_output : 500:quiet :/usr/bin/pgrep -f "^/usr/bin/tcpsvd -E 0.0.0.0 1021" chain_failure : nickel_setting : disable : force_wifi # ## FTP Toggle menu_item : main : FTP Start : cmd_output : 500:quiet :/usr/bin/pkill -f "^/usr/bin/tcpsvd -E 0.0.0.0 1021" chain_success:skip:10 chain_failure : cmd_spawn : quiet :exec /usr/bin/tcpsvd -E 0.0.0.0 1021 /usr/sbin/ftpd -w -t 30 /mnt/onboard chain_success:skip:2 chain_failure : dbg_toast : Error starting FTP server on port 1021 chain_success:skip:-1 chain_success : cmd_output : 500:quiet :grep -x 'ForceWifiOn=true' '/mnt/onboard/.kobo/Kobo/Kobo eReader.conf' chain_failure : nickel_setting : enable : force_wifi chain_success : nickel_wifi : autoconnect_silent chain_success : dbg_toast : Started FTP server on port 1021 chain_success : cmd_spawn : quiet :sed -i '/^## FTP Toggle/ { n; s/^\([^:]*:[^:]*:\)[^:]*\(:.*\)$/\1 FTP Stop \2/ }' /mnt/onboard/.adds/nm/config chain_always:skip:-1 chain_success : dbg_toast : Stopped FTP server on port 1021 chain_success : cmd_spawn : quiet :sed -i '/^## FTP Toggle/ { n; s/^\([^:]*:[^:]*:\)[^:]*\(:.*\)$/\1 FTP Start \2/ }' /mnt/onboard/.adds/nm/config chain_success : cmd_output : 500:quiet :/usr/bin/pgrep -f "^/usr/bin/tcpsvd -E 0.0.0.0 2023" chain_failure : nickel_setting : disable : force_wifi # ## Library Menu # # ## Light Toggle menu_item : library : Light On : cmd_output : 500: quiet :/bin/sh -c 'if [ "$(cat /sys/class/backlight/mxc_msp430.0/actual_brightness)" -eq "0" ]; then exit 1; else exit 0; fi' chain_success:skip:3 chain_failure : cmd_spawn : quiet :ioctl /dev/ntx_io 241 -v 8 chain_success : cmd_spawn : quiet :sed -i '/^## Light Toggle/ { n; s/^\([^:]*:[^:]*:\)[^:]*\(:.*\)$/\1 Light Off \2/ }' /mnt/onboard/.adds/nm/config chain_always:skip:-1 chain_success : cmd_spawn : quiet :ioctl /dev/ntx_io 241 -v 0 chain_success : cmd_spawn : quiet :sed -i '/^## Light Toggle/ { n; s/^\([^:]*:[^:]*:\)[^:]*\(:.*\)$/\1 Light On \2/ }' /mnt/onboard/.adds/nm/config # ## Reading Menu # ## Light Toggle menu_item : reader : Light On : cmd_output : 500: quiet :/bin/sh -c 'if [ "$(cat /sys/class/backlight/mxc_msp430.0/actual_brightness)" -eq "0" ]; then exit 1; else exit 0; fi' chain_success:skip:3 chain_failure : cmd_spawn : quiet :ioctl /dev/ntx_io 241 -v 8 chain_success : cmd_spawn : quiet :sed -i '/^## Light Toggle/ { n; s/^\([^:]*:[^:]*:\)[^:]*\(:.*\)$/\1 Light Off \2/ }' /mnt/onboard/.adds/nm/config chain_always:skip:-1 chain_success : cmd_spawn : quiet :ioctl /dev/ntx_io 241 -v 0 chain_success : cmd_spawn : quiet :sed -i '/^## Light Toggle/ { n; s/^\([^:]*:[^:]*:\)[^:]*\(:.*\)$/\1 Light On \2/ }' /mnt/onboard/.adds/nm/config Note that if you reboot the device with FTP or Telnet on, the menu labels will be out of sync, but once you use them once they will resync. The light menu option will also be out of sync if you change it manually instead, but will also resync once you use it once. It's set to turn it on to level 8, which of course can be changed Code:
ioctl /dev/ntx_io 241 -v 8 <-- set this to the level you want Last edited by AsherMaximum; 02-05-2025 at 04:50 PM. |
![]() |
![]() |
![]() |
#2 |
Enthusiast
![]() Posts: 49
Karma: 10
Join Date: Jun 2010
Device: none
|
Hi nice idea, could you do this for Screenshots?
Tested it out and it doesn't enable wifi if wifi is turned off. Last edited by remlap; 02-05-2025 at 05:24 PM. |
![]() |
![]() |
![]() |
#3 | |
Member
![]() Posts: 13
Karma: 10
Join Date: Jan 2025
Device: Kobo Libra 2
|
Quote:
The force_wifi part is just to make the wifi connection not turn off while the ftp server is up, since the Kobo will disconnect the wifi when it's not actively using it. If you normally leave your wifi off, just add an enable line above both the autoconnect_silent lines: Code:
chain_success : nickel_wifi : enable chain_success : nickel_wifi : autoconnect_silent The screenshots one is simple: Code:
# ## Screenshots Toggle menu_item : main : Turn Screenshots On : nickel_setting : toggle : screenshots chain_success : cmd_output : 500:quiet :grep -x 'Screenshots=true' '/mnt/onboard/.kobo/Kobo/Kobo eReader.conf' chain_success : cmd_spawn : quiet :sed -i '/^## Screenshots Toggle/ { n; s/^\([^:]*:[^:]*:\)[^:]*\(:.*\)$/\1Turn Screenshots Off \2/ }' /mnt/onboard/.adds/nm/config chain_failure : cmd_spawn : quiet :sed -i '/^## Screenshots Toggle/ { n; s/^\([^:]*:[^:]*:\)[^:]*\(:.*\)$/\1Turn Screenshots On \2/ }' /mnt/onboard/.adds/nm/config Last edited by AsherMaximum; 02-05-2025 at 06:10 PM. |
|
![]() |
![]() |
![]() |
#4 |
Enthusiast
![]() Posts: 49
Karma: 10
Join Date: Jun 2010
Device: none
|
ftp and screenshots work great. Also could you have the toast display the kobos IP?
Last edited by remlap; 02-05-2025 at 06:52 PM. |
![]() |
![]() |
![]() |
#5 |
Member
![]() Posts: 13
Karma: 10
Join Date: Jan 2025
Device: Kobo Libra 2
|
There's an example of how to show the IP address in the doc file that comes with the install, just switch out the toast line for that one.
|
![]() |
![]() |
![]() |
#6 |
Member
![]() Posts: 13
Karma: 10
Join Date: Jan 2025
Device: Kobo Libra 2
|
For the light level, I updated it to this, otherwise the light level will not persists after the device goes to sleep:
Code:
menu_item : library : Light On : cmd_output : 500: quiet :/bin/sh -c 'if [ "$(cat /sys/class/backlight/mxc_msp430.0/actual_brightness)" -eq "0" ]; then exit 1; else exit 0; fi' chain_success:skip:4 chain_failure : cmd_spawn : quiet :ioctl /dev/ntx_io 241 -v 8 chain_success : cmd_spawn : quiet :sed -i '/^## Light Toggle/ { n; s/^\([^:]*:[^:]*:\)[^:]*\(:.*\)$/\1 Light Off \2/ }' /mnt/onboard/.adds/nm/config chain_success : cmd_spawn : quiet :sed -i-E 's/^FrontLightLevel=[0-9]+/FrontLightLevel=8/' '/mnt/onboard/.kobo/Kobo/Kobo eReader.conf' chain_always:skip:-1 chain_success : cmd_spawn : quiet :ioctl /dev/ntx_io 241 -v 0 chain_success : cmd_spawn : quiet :sed -i '/^## Light Toggle/ { n; s/^\([^:]*:[^:]*:\)[^:]*\(:.*\)$/\1 Light On \2/ }' /mnt/onboard/.adds/nm/config chain_success : cmd_spawn : quiet :sed -i-E 's/^FrontLightLevel=[0-9]+/FrontLightLevel=0/' '/mnt/onboard/.kobo/Kobo/Kobo eReader.conf' |
![]() |
![]() |
![]() |
#7 |
Member
![]() Posts: 13
Karma: 10
Join Date: Jan 2025
Device: Kobo Libra 2
|
That should be sed -i -E, not -i-E
|
![]() |
![]() |
![]() |
#8 | |
Enthusiast
![]() Posts: 49
Karma: 10
Join Date: Jun 2010
Device: none
|
Quote:
Code:
# ## FTP Toggle menu_item : main : FTP Start : cmd_output : 500:quiet :/usr/bin/pkill -f "^/usr/bin/tcpsvd -E 0.0.0.0 1021" chain_success:skip:11 chain_failure : cmd_spawn : quiet :exec /usr/bin/tcpsvd -E 0.0.0.0 1021 /usr/sbin/ftpd -w -t 30 /mnt/onboard chain_success:skip:2 chain_failure : dbg_toast : Error starting FTP server chain_success:skip:-1 chain_success : cmd_output : 500:quiet :grep -x 'ForceWifiOn=true' '/mnt/onboard/.kobo/Kobo/Kobo eReader.conf' chain_failure : nickel_setting : enable : force_wifi chain_success : nickel_wifi : enable chain_success : nickel_wifi : autoconnect_silent chain_success : cmd_output : 500:/sbin/ifconfig | /usr/bin/awk '/inet addr/{print substr($2,6)}' | sed 's/$/:1021/' | sed 's/^/Started FTP server on /' chain_success : cmd_spawn : quiet :sed -i '/^## FTP Toggle/ { n; s/^\([^:]*:[^:]*:\)[^:]*\(:.*\)$/\1 FTP Stop \2/ }' /mnt/onboard/.adds/nm/menu chain_always:skip:-1 chain_success : dbg_toast : Stopped FTP server chain_success : cmd_spawn : quiet :sed -i '/^## FTP Toggle/ { n; s/^\([^:]*:[^:]*:\)[^:]*\(:.*\)$/\1 FTP Start \2/ }' /mnt/onboard/.adds/nm/menu chain_success : cmd_output : 500:quiet :/usr/bin/pgrep -f "^/usr/bin/tcpsvd -E 0.0.0.0 2023" chain_failure : nickel_setting : disable : force_wifi # Code:
chain_success : cmd_output : 500:/sbin/ifconfig | /usr/bin/awk '/inet addr/{print substr($2,6)}' | sed 's/$/:1021/' | sed 's/^/Started FTP server on /' Last edited by remlap; 02-06-2025 at 08:07 AM. |
|
![]() |
![]() |
![]() |
#9 |
Connoisseur
![]() Posts: 55
Karma: 10
Join Date: Mar 2015
Device: InkPad
|
Is it possible to switch the tap zone settings by Nickel Menu?
|
![]() |
![]() |
![]() |
#10 |
Enthusiast
![]() Posts: 49
Karma: 10
Join Date: Jun 2010
Device: none
|
Code:
# ## Dark Mode Toggle menu_item : reader : Enable Dark Mode : nickel_setting : toggle : dark_mode chain_success : cmd_spawn : quiet :sed -i '/^## Dark Mode Toggle/ { n; s/^\([^:]*:[^:]*:\)[^:]*\(:.*\)$/\1Disable Dark Mode \2/ }' /mnt/onboard/.adds/nm/menu chain_failure : cmd_spawn : quiet :sed -i '/^## Dark Mode Toggle/ { n; s/^\([^:]*:[^:]*:\)[^:]*\(:.*\)$/\1Enable Dark Mode \2/ }' /mnt/onboard/.adds/nm/menu Last edited by remlap; 02-11-2025 at 02:21 PM. |
![]() |
![]() |
![]() |
#11 | |
Enthusiast
![]() Posts: 49
Karma: 10
Join Date: Jun 2010
Device: none
|
Quote:
|
|
![]() |
![]() |
![]() |
#12 |
Enthusiast
![]() Posts: 49
Karma: 10
Join Date: Jun 2010
Device: none
|
I have decided dark mode toggle is fine you can see if its enabled or not
How do I go about turning this into a dynamic menu item for now its two Code:
# ## Page Turner Toggle Menu menu_item : main : Enable Page Turner : nickel_bluetooth : enable chain_success : cmd_spawn : quiet : sleep 3 && bluetoothctl connect MACADDRES menu_item : main : Disable Page Turner : nickel_bluetooth : disable # |
![]() |
![]() |
![]() |
#13 | |
Member
![]() Posts: 13
Karma: 10
Join Date: Jan 2025
Device: Kobo Libra 2
|
Quote:
Find a way to check the setting, and that will let you change the menu. You can probably do it by grepping the "Kobo eReader.conf" file for a string, not sure what the string is when dark mode is on, but you can easily check that. |
|
![]() |
![]() |
![]() |
#14 |
Member
![]() Posts: 13
Karma: 10
Join Date: Jan 2025
Device: Kobo Libra 2
|
I would think so - somewhere in the Kobo conf file, there is an integer that sets what the reading settings are. You'd need to figure out what those integers mean, and setup sed commands to replace it with what you want.
|
![]() |
![]() |
![]() |
#15 |
Enthusiast
![]() Posts: 49
Karma: 10
Join Date: Jun 2010
Device: none
|
Dark mode is not my concern now it's a Bluetooth enabled or disabled.
|
![]() |
![]() |
![]() |
Thread Tools | Search this Thread |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Deleting Labels | Ernstig | Calibre | 2 | 08-19-2024 05:10 AM |
Deleting Labels | Ernstig | Calibre | 1 | 02-19-2023 11:09 AM |
working with text labels | Fynjisx | Calibre | 5 | 08-26-2022 07:20 AM |
Mac Labels | Lonniec3 | Calibre | 1 | 09-21-2012 01:39 PM |
K3 Keyboard Labels | clintbradford | Amazon Kindle | 10 | 08-28-2010 03:14 AM |