I agree with you that most books do not follow a logical path when defining thermodynamics terms. Even great books such as Fermi's and Pauli's.
The first thing you need to define is the concept of thermodynamic variables.
Thermodynamic variables are macroscopic quantities whose values depend
only on the current state of thermodynamic equilibrium of the system.
By thermodynamic equilibrium we mean that those variables do not change with time. Their values on the equilibrium cannot depend on the process by which the system achieved the equilibrium. Example of thermodynamic variables are: Volume, pressure, surface tension, magnetization... The equilibrium values of these quantities define the thermodynamic state of a system.
When a thermodynamic system is not isolated, its thermodynamic variables can change under influence of the surrounding. We say the system and the surrounding are in thermal contact. When the system is not in thermal contact with the surrounding we say the system is adiabatically isolated. We can define that,
Two bodies are in thermal equilibrium when they - in thermal contact
with each other - have constant thermodynamic variables.
Now we are able to define temperature. From a purely thermodynamic point of view this is done through the Zeroth Law. A detailed explanation can be found in this post. Basically,
We say that two bodies have the same temperature if and only if they
are in thermal equilibrium.
Borrowing the mechanical definition of work one can - by way of experiments - observe that the work needed to achieve a given change in the thermodynamic state of an adiabatically isolated system is always the same. It allows us to define this value as an internal energy change,
$$W=-\Delta U.$$
By removing the adiabatic isolation we notice that the equation above is no longer valid and we correct it by adding a new term,
$$\Delta U=Q-W,$$
so
The heat $Q$ is the energy the system exchange with the surrounding in
a form that is not work.
Notice that I have skipped more basic definitions such as thermodynamic system and isolated system but this can be easily and logically defined in this construction.
and so the direction of heat flow was just a matter of definition.
It is not just a matter of definition. It's a matter of observation. Heat is never observed to flow naturally or spontaneously from a low temperature substance to a high temperature substance. For that to happen, work must be done (as, for example, in the case of refrigerators and heat pumps.)
Before the second law was developed we had the first law. That law is a statement of conservation of energy. If heat heat were to flow from a cold to hot object, the heat lost by the cold object would equal the heat gained by the hot object and the first law would be satisfied. But since this never happens, a new law was needed that made such a flow of heat impossible .
Although the wording of the "argument" is rather awkward, at least to me, it is true that when heat transfers from the hotter system there is a decrease in both the entropy and internal energy (dU) of the hot system and there is an increase in both the entropy and internal energy of the cold system. The important distinction is internal energy is conserved but entropy is not, unless the heat transfer is "reversible".
The decrease in internal energy of the hot system exactly equals the increase in internal energy of the cold system, per the first law, for a total change in internal energy of zero. On the other hand, for any finite difference in temperature between the hot and cold system, the decrease in entropy of the hot system is less than the increase in entropy of the cold system, for a total entropy change greater than zero.
If the hot and cold systems are thermal reservoirs (constant temperature sources and receivers of heat), the entropy change of the hot system is
$$\Delta S_{H}=-\frac{Q}{T_H}$$
The entropy change of the cold system is
$$\Delta S_{C}=+\frac{Q}{T_L}$$
The total entropy change is
$$\Delta S_{tot}=+\frac{Q}{T_L}-\frac{Q}{T_H}$$
You will note that for all $T_{H}>T_{L}$, $\Delta S_{tot}>0$.
So, is the direction of heat flow because of definition or the 2nd law
of thermodynamics?
No. The natural direction of heat flow from hot to cold is an observable fact of nature. The second does not dictate nature. The second law reflects nature. The second law says that
$$\Delta S_{tot}=\Delta S_{sys}+\Delta S_{sur}\ge0$$
Where the equal sign applies to a reversible transfer of heat, i.e., when the difference between $T_H$ and $T_L$ approaches zero.
If heat flowed from cold to hot, the signs for the entropy changes in the first two equations above would be reversed, resulting in $\Delta S_{tot}<0$ in violation of the second law.
Hope this helps.
Best Answer
For a mathematician, the answer is that the customary calibration of temperature---Kelvin's absolute temperature---has enormous advantages over all its rivals (including the one proposed in the above query): it is essentially the only one that leads to the mapping from the pressure-volume plane into the temperature-entropy plane described by the equations of state being area-preserving (recall that this area in both planes can be interpreted as energy). Analytically, this means that if the equations of state have the form $T=f(p,V), S=g(p,V)$ then $f_1g_2-f_2g_1 = 1$ (subscripts denote partial derivatives) and this is equivalent to the Maxwell relations.
We quote from Kelvin's original article: "The characteristic property of the scale which I now propose is, that all degress have the same value; that is, that a unit of heat descending from a body A at the temperature $T$ degrees of this scale, to a body B at the temperature $(T-1)$ degrees would give out the same mechanical effect, whatever the number $T$. This may justly be termed an absolute scale."
One of the central incidents in the history of physics is surely the search for the true scale of temperature (Maxwell's treatise on Heat begins with a lucid discussion of the problems involved) and its solution (the practical one due to Regnault and the theoretical one due to Kelvin---it is no concidence that the latter had worked in the former's laboratory) must be one of the most significant scientific achievements of the 19th century.