In order to generalize the well-known spanwise-oscillating-wall technique for drag reduction, non-sinusoidal oscillations of a solid wall are considered as a means to alter the skin-friction drag in a turbulent channel flow. A series of Direct Numerical Simulations is conducted to evaluate the control performance of nine different temporal waveforms, in addition to the usual sinusoid, systematically changing the wave amplitude and the period for each waveform. The turbulent average spanwise motion is found to coincide with the laminar Stokes solution that is constructed, for the generic waveform, through harmonic superposition. This allows us to define and compute, for each waveform, a new penetration depth of the Stokes layer which correlates with the amount of turbulent drag reduction, and eventually to predict both turbulent drag reduction and net energy saving rate for arbitrary waveforms. Among the waveforms considered, the maximum net energy saving rate is obtained by the sinusoidal wave at its optimal amplitude and period. However, the sinusoid is not the best waveform at every point in the parameter space. Our predictive tool offers simple guidelines to design waveforms that outperform the sinusoid for given (suboptimal) amplitude and period of oscillation. This is potentially interesting in view of applications, where physical limitations often preclude the actuator to reach its optimal operating conditions.