Forum › Forums › General › Tips and Tricks › Fully GUI way to select the system’s Time Zone
- This topic has 3 replies, 2 voices, and was last updated Jan 9-3:30 am by PPC.
-
AuthorPosts
-
January 7, 2020 at 8:43 am #31477Member
PPC
Hi! “Programming” is my way to deal with stress. The set time & date script has been bugging me since I adapted Skidoo’s original script and sent it over to anticapitalista, for 2 reasons: it has no windows decorations and (mainly) is depends on a CLI tool to select the correct Time Zone.
So I googled my way into patching together to this little script that’s a (I hope, a correctly working) fully GUI way to select and change the system’s time zone (more “modern” looking than what antiX – that is fast but uses the terminal – and even MX linux – that requires the user to type the timezone- use right now).If anyone wants to (hello there skidoo, anti and the rest of the team), please test it. If this has positive feedback, when I have the time, I’ll try to insert it into the current Set time & date script.
I hope the forum does not mangle the code… It fits right into the lean and mean motto: it’s a script with only 5 lines!If you want to test this, just past the code into a terminal, change the time zone and then select the correct time zone again. You may have to restart your window manager for the change to apply to the toolbar clock…
P.
##Identify the timezone you want to configure and create a symlink: sudo ln -s /usr/share/zoneinfo/$tz /etc/localtime # List all timezones available: cd /usr/share/zoneinfo/posix && find * -type f -or -type l | sort > ~/timezones.txt # Run menu to select timezone, that is sent to the variable "tz" tz=( $(yad --title="--dclick-action=CMD" --width=300 --height=200 --separator=" " --list --dclick-action="viewnior" --column=TimeZones < ~/timezones.txt)) ##Delete the current /etc/localtime file or symlink: sudo rm -f /etc/localtime ##Use the selected timezone and create a symlink: sudo ln -s /usr/share/zoneinfo/$tz /etc/localtime ## You can confirm the change either by listing the /etc/localtime file or issuing the date command: date- This topic was modified 3 years, 4 months ago by PPC.
January 8, 2020 at 10:36 am #31496MemberPPC
::Anticapitalista, and everyone else:
Here’s the set time and date script, updated to use the new fully GUI way to select the time zone (no bugs, I hope, I tested it)
(save this as a .sh file and make it executable to test it…P.
- This reply was modified 3 years, 4 months ago by PPC.
- This reply was modified 3 years, 4 months ago by PPC.
January 8, 2020 at 11:53 am #31501Anonymous
::refrained from replying earlier, now relieved to at least see the errcheck for empty tz
(in case user clicked OK without making a selection)--title="--dclick-action=CMD"
That bit is just plain wonky.
CMD is undefined; the double dash within a quoted string would just be printed literally (or yad just treats the title option as malformed and ignores it?)viewnior?
that must be a copypasta leftover, eh?If you prefer to amend the undecorated window (i would not favor doing so) that’s just a design detail.
However, the proposed change would bring a regression, in terms of usability.
Instead of drill-down (region–}zone), users would be subjected to scrolling through a looooooong list of choices within a comparatively tiny box… and, under gtk3 default theming, would subjected to “jumpTo” scrollbar behavior (unable to move one screenful at a time by clicking above or below the scrollbar handle).January 9, 2020 at 3:30 am #31509MemberPPC
::--title="--dclick-action=CMD"
That bit is just plain wonky.
CMD is undefined; the double dash within a quoted string would just be printed literally (or yad just treats the title option as malformed and ignores it?)viewnior?
that must be a copypasta leftover, eh?If you prefer to amend the undecorated window (i would not favor doing so) that’s just a design detail.
However, the proposed change would bring a regression, in terms of usability.
Instead of drill-down (region–}zone), users would be subjected to scrolling through a looooooong list of choices within a comparatively tiny box… and, under gtk3 default theming, would subjected to “jumpTo” scrollbar behavior (unable to move one screenful at a time by clicking above or below the scrollbar handle).Hi Skidoo- yes, you were stop on everything you said: the “CMD” and “viewnior” were leftovers from the scripts I found online to learn how to do what I wanted to do- dump all the time zones to a text file, then have each time zone selectable using YAD and finally, using the selected variable to set the timezone. Believe it or not the last part was the trickiest…
The user can use page up/page down, or the scroll bar to quickly find the correct time zone. Unfortunatly I found no way to make YAD respond to keyboard input (example: pressing “E” to jump to “Europe”- exactly the opposite behavior that “dpkg-reconfigure tzdata” has)
I do get that probably using the cli “dpkg-reconfigure tzdata” is faster than my proposed yad dialog- it parses continents/seas/etc and then cities. But it’s a cli application that does not respond to mouse input – that’s what most regular, non geeky, users are used to. People are used, on on-line forms, etc, to scroll down to the option then want to select.
Since I don’t know how to add mouse input to “dpkg-reconfigure tzdata”, using yad was the logical step to me.
It was kind of a personal challenge, so see if I could find out how to do that. Knowing how to have the output of any command selectable under YAD, and running a command from there, opens infinite opportunities to have GUI’s for so much stuff users can only do using the terminal…
If I have the time (and patience) I can think of a better yad script- making it act just like “dpkg-reconfigure tzdata”- first present a “continents/seas/etc” list and then present the relevant cities… It would make this script act almost 100% like “dpkg-reconfigure tzdata” but with mouse input…
I do theoretically know how to do that, but it’s way to complex for me to easily do in a morning or afternoon, like I did the previous script.Anyway, the script is out there, for anyone to test or use. I know selecting a time zone after installing a OS isn’t something most people ever need to do- but in a post about not connecting to wifi, someone said they needed to change the time/date- and I thought- “Oh good! At least the set time & date script probably helped someone!”
P.
- This reply was modified 3 years, 4 months ago by PPC.
-
AuthorPosts
- You must be logged in to reply to this topic.