For example, if I change the sound volume by the ubuntu desktop widget, I think it will issue some commands to the shell or run a script.
Is it possible to see what it runs?
Doing something in the GUI does not, in general, invoke shell commands. It happens sometimes, but it's uncommon. Rather, both GUI and command line programs (including shells) call the same underlying programming interfaces.
If you want to understand how a program does something, check its documentation or its source code. You can try to observe it, but it can be difficult to figure out.
strace -p1234 -o widget.strace
Perform the action you want to observe, then kill strace (Ctrl+C in the terminal). Look at the output file and try to figure it out. You'll see a lot of communication with the X server (
write calls on a particular file description) due to the GUI actions. If the action is performed by the X server, you'll need to analyze that protocol further. You may also observe remote calls via D-Bus; to understand these, run
dbus-monitor to get a human-readable trace of the D-Bus traffic. Otherwise look at what else the program is doing.
Sound on Ubuntu normally goes via Pulseaudio. The application uses D-Bus to communicate with the Pulseaudio server. Pulseaudio has a command line interface with programs whose name begins with
pavucontrol to control the volume.