Register Guidelines E-Books Search Today's Posts Mark Forums Read

Go Back   MobileRead Forums > E-Book Readers > Kobo Reader

Notices

Reply
 
Thread Tools Search this Thread
Old 02-05-2025, 04:47 PM   #1
AsherMaximum
Member
AsherMaximum began at the beginning.
 
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
The FTP and Telnet toggles also turn on the Forced Wifi option if it's not already on, and turn it off once it's the last thing running. Meaning that if you start both Telnet and FTP, and then stop Telnet, the ForcedWifi setting won't be turned off untill you stop the FTP server.

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.
AsherMaximum is offline   Reply With Quote
Old 02-05-2025, 05:11 PM   #2
remlap
Connoisseur
remlap began at the beginning.
 
Posts: 53
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.
remlap is offline   Reply With Quote
Advert
Old 02-05-2025, 06:06 PM   #3
AsherMaximum
Member
AsherMaximum began at the beginning.
 
Posts: 13
Karma: 10
Join Date: Jan 2025
Device: Kobo Libra 2
Quote:
Tested it out and it doesn't enable wifi if wifi is turned off.
Ah, didn't think of that one - I always leave wifi on since it turns the connection off when it's not in use.
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
You'll also need to update the chain_success:skip:11 to 12 and chain_success:skip:10 to 11, since there is now an extra line in that section of the chain.

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
Of course, just like the others, if you reboot with screenshots on, it will be out of sync until you use the button.

Last edited by AsherMaximum; 02-05-2025 at 06:10 PM.
AsherMaximum is offline   Reply With Quote
Old 02-05-2025, 06:25 PM   #4
remlap
Connoisseur
remlap began at the beginning.
 
Posts: 53
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.
remlap is offline   Reply With Quote
Old 02-05-2025, 10:25 PM   #5
AsherMaximum
Member
AsherMaximum began at the beginning.
 
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.
AsherMaximum is offline   Reply With Quote
Advert
Old 02-05-2025, 10:31 PM   #6
AsherMaximum
Member
AsherMaximum began at the beginning.
 
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'
AsherMaximum is offline   Reply With Quote
Old 02-05-2025, 10:48 PM   #7
AsherMaximum
Member
AsherMaximum began at the beginning.
 
Posts: 13
Karma: 10
Join Date: Jan 2025
Device: Kobo Libra 2
That should be sed -i -E, not -i-E
AsherMaximum is offline   Reply With Quote
Old 02-06-2025, 07:56 AM   #8
remlap
Connoisseur
remlap began at the beginning.
 
Posts: 53
Karma: 10
Join Date: Jun 2010
Device: none
Quote:
Originally Posted by AsherMaximum View Post
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.
I am learning as I go, I am a noob when it comes to bash commands and kobo.

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

#
This works but not when wifi is disabled is there anyway to wait before wifi to connect before it runs

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 /'
I think I will just leave my wifi always enabled

Last edited by remlap; 02-06-2025 at 08:07 AM.
remlap is offline   Reply With Quote
Old 02-06-2025, 09:27 PM   #9
f_coco
Connoisseur
f_coco began at the beginning.
 
Posts: 56
Karma: 10
Join Date: Mar 2015
Device: InkPad
Is it possible to switch the tap zone settings by Nickel Menu?
f_coco is offline   Reply With Quote
Old 02-11-2025, 02:11 PM   #10
remlap
Connoisseur
remlap began at the beginning.
 
Posts: 53
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
Any help with Dark Mode toggle?

Last edited by remlap; 02-11-2025 at 02:21 PM.
remlap is offline   Reply With Quote
Old 02-13-2025, 02:43 PM   #11
remlap
Connoisseur
remlap began at the beginning.
 
Posts: 53
Karma: 10
Join Date: Jun 2010
Device: none
Quote:
Originally Posted by remlap View Post
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
Any help with Dark Mode toggle?
Anyone?
remlap is offline   Reply With Quote
Old 02-16-2025, 02:46 PM   #12
remlap
Connoisseur
remlap began at the beginning.
 
Posts: 53
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
#
remlap is offline   Reply With Quote
Old 02-18-2025, 01:30 PM   #13
AsherMaximum
Member
AsherMaximum began at the beginning.
 
Posts: 13
Karma: 10
Join Date: Jan 2025
Device: Kobo Libra 2
Quote:
How do I go about turning this into a dynamic menu item for now its two
You need a way of knowing if dark mode is on or not, that's what the success/failure chains key off of. For the FTP toggle, it tries to stop the FTP server. If it is successful in stopping it, that means it was on, and now it's off, so I change the menu item to "Start FTP". If it fails, that means it wasn't on, so I start the FTP server, and then change the menu item to "Stop FTP"

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.
AsherMaximum is offline   Reply With Quote
Old 02-18-2025, 01:31 PM   #14
AsherMaximum
Member
AsherMaximum began at the beginning.
 
Posts: 13
Karma: 10
Join Date: Jan 2025
Device: Kobo Libra 2
Quote:
Originally Posted by f_coco View Post
Is it possible to switch the tap zone settings by Nickel Menu?
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.
AsherMaximum is offline   Reply With Quote
Old 02-18-2025, 01:37 PM   #15
remlap
Connoisseur
remlap began at the beginning.
 
Posts: 53
Karma: 10
Join Date: Jun 2010
Device: none
Dark mode is not my concern now it's a Bluetooth enabled or disabled.
remlap is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
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


All times are GMT -4. The time now is 03:21 PM.


MobileRead.com is a privately owned, operated and funded community.