The only solution I found so far is the following.
Implementing custom component Buttons
which implements flexipage:availableForRecordHome
and force:hasRecordId
interfaces
<aura:component implements="flexipage:availableForRecordHome,force:hasRecordId" access="global" >
<lightning:button variant="brand" label="XXXX" onclick="{! c.action }"/>
</aura:component>
and contains one or several buttons.
In the lightning controller I can define the action for button click event.
({
action : function(component, event, helper) {
alert('x');
}
})
Then I can put that component to User Records Page just beneath the Highlights Panel.
and thus having it on user layout in Lightning Experience interface.
For Salesforce Classic interface I have to create Lightning Out application
<aura:application extends="ltng:outApp" >
<aura:dependency resource="c:Buttons"/>
</aura:application>
Then Visualforce page which will use Lightning Out Application and Lightning Component
<apex:page standardStylesheets="false" showHeader="false" sidebar="false" standardController="User" >
<apex:includeScript value="/lightning/lightning.out.js" />
<div id="lightning" />
<script>
$Lightning.use("c:ButtonsOut", function() {
// Write a function that creates the component on the page
$Lightning.createComponent("c:Buttons",
{},
"lightning",
function(cmp) {
});
});
</script>
<style>
body{
margin: 0;
}
</style>
</apex:page>
Then I have to modify layout and put page to the top available section of the User Layout.
Unfortunately, I can't put it above the Standards Fields section. Nor by point and click configuration neither by layout XML ANT Deployment Tool hacking.