top of page
  • Writer's pictureIGEL Community

How to: setting up a scrolling command for Firefox in IGEL OS

Written by Milan Potrok , IGEL COMMUNITY MEMBER OF THE YEAR


In our IGEL Community we had the request to seting up a scrolling command for Firefox on IGEL OS. The challenge was to have a website that cannot fit the screen, no matter what type of resolution or DPI scaling was configured. So the request was a command to set the horizontal scroll to always go to the right, and then scroll up and down.


Here is a example "Firefox Scroller Custom-Application", that:

  1. Is set to start on auto-launch on boot, (also called by CTRL-ALT-SHIFT Q)

  2. Launches firefox and opens ACME.COM in a 500x500 window (to demo scrolling)

  3. Scrolls around the window a bunch of times

  4. currently defined 9 difference sequences or cases, but customize to your own liking

  5. some example sequences shown

  6. Step 1 reloads the webpage and starts all over again

  7. RUNS FOREVER....or until the browser tab with that name is closed

For your own testing change:

  1. Set s="Your Webpage Title";

  2. Set DEBUG=false; when you don't want to flood the syslog with messages

  3. Change sleep 2; with your own interval

# With comments
DEBUG=true;  # syslog will show lots of debug logs with this true
s="ACME";    # set website title for partial xdotool match later
if [ .${DEBUG}. = .true. ]; then set -x; fi;   # more verbose logging
logger -it "custom-firefox-scroller-ca" "start firefox with url";
# launch firefox with url as background process
( firefox --width 500 --height 500 http://acme.com )&
sleep 6;   # wait for firefox launch
i=0;       # counter for logic conditions
# loop until firefox closed
while true; do
  sleep 2;
  if ! xdotool search --classname firefox search --name $s windowfocus > /dev/null; then
    logger -it "custom-firefox-scroller-ca" "firefox with website title [$s] not found, exiting custom app";
    exit 0;  # exit if firefox not running
  fi;
  i=$((i+1));
  # define number of possible step values (10), using modulus operator, and assign current step to variable j
  j=$((i%10));  
  if [ .${DEBUG}. = .true. ]; then echo "custom-firefox-scroller-ca: i=$i j=$j"; fi;
  case $j in
  1)
    xdotool search --name $s key F5;
    sleep 2;
    xdotool search --name $s key Home Right Right Right Right Right Right;;
  2|3|4)
    xdotool search --name $s key Down Down;;
  5|6|7)
    xdotool search --name $s key Up Up;;
  8)
    xdotool search --name $s key Home;;
  9)
    xdotool search --name $s key End;;
  esac;
done;

And now make it a single line of “commands” that is used in the definition of a custom-application. This will run in user context (don't exceed 4000 characters):

  1. remove all the comments

  2. make sure each command list ends with command list terminator (ie. semicolon;)

  3. combine into one long messy line

  4. Note that this executes in “/bin/sh”, or dash shell, by default

  5. Don’t put semicolon after the background (&) operator

DEBUG=true; s="ACME"; if [ .${DEBUG}. = .true. ]; then set -x; fi; logger -it "custom-firefox-scroller-ca" "start firefox with url"; ( firefox --width 500 --height 500 http://acme.com )& sleep 6; i=0; while true; do sleep 2; if ! xdotool search --classname firefox search --name $s windowfocus > /dev/null; then logger -it "custom-firefox-scroller-ca" "firefox with website title [$s] not found, exiting custom app"; exit 0; fi; i=$((i+1)); j=$((i%10)); if [ .${DEBUG}. = .true. ]; then echo "custom-firefox-scroller-ca: i=$i j=$j"; fi; case $j in 1) xdotool search --name $s key F5; sleep 2; xdotool search --name $s key Home Right Right Right Right Right Right;; 2|3|4) xdotool search --name $s key Down Down;; 5|6|7) xdotool search --name $s key Up Up;; 8) xdotool search --name $s key Home;; 9) xdotool search --name $s key End;; esac; done;

And with any luck, it might behave like the attached animated-gif. The gif shows browser and the debug syslog output side-by-side to show the script logic as it executes.






Read more here:

https://igelcommunity.slack.com/archives/C8GP9JHQE/p1683150767498799?thread_ts=1683055842.019449&cid=C8GP9JHQE



Comments


bottom of page