@@ -19,6 +19,7 @@ import (
1919 "fmt"
2020 "os"
2121 "strconv"
22+ "strings"
2223
2324 "github.com/godbus/dbus/v5"
2425)
@@ -158,7 +159,6 @@ func userFromInterfaces(user []interface{}) (*User, error) {
158159
159160// GetActiveSession may be used to get the session object path for the current active session
160161func (c * Conn ) GetActiveSession () (dbus.ObjectPath , error ) {
161- var activeSessionPath dbus.ObjectPath
162162 var seat0Path dbus.ObjectPath
163163 if err := c .object .Call (dbusInterface + ".GetSeat" , 0 , "seat0" ).Store (& seat0Path ); err != nil {
164164 return "" , err
@@ -174,7 +174,7 @@ func (c *Conn) GetActiveSession() (dbus.ObjectPath, error) {
174174 return "" , fmt .Errorf ("failed to typecast active session map" )
175175 }
176176
177- activeSessionPath , ok = activeSessionMap [1 ].(dbus.ObjectPath )
177+ activeSessionPath , ok : = activeSessionMap [1 ].(dbus.ObjectPath )
178178 if ! ok {
179179 return "" , fmt .Errorf ("failed to typecast dbus active session Path" )
180180 }
@@ -184,10 +184,9 @@ func (c *Conn) GetActiveSession() (dbus.ObjectPath, error) {
184184// GetSessionUser may be used to get the user of specific session
185185func (c * Conn ) GetSessionUser (sessionPath dbus.ObjectPath ) (* User , error ) {
186186 if len (sessionPath ) == 0 {
187- return nil , fmt .Errorf ("Empty sessionPath" )
187+ return nil , fmt .Errorf ("empty sessionPath" )
188188 }
189189
190- var user User
191190 activeSessionObj := c .conn .Object (dbusDest , sessionPath )
192191 sessionUserName , err := activeSessionObj .GetProperty (dbusDest + ".Session.Name" )
193192 if err != nil {
@@ -215,23 +214,23 @@ func (c *Conn) GetSessionUser(sessionPath dbus.ObjectPath) (*User, error) {
215214 return nil , fmt .Errorf ("failed to typecast user field 1 to ObjectPath" )
216215 }
217216
218- user = User {UID : uid , Name : sessionUserName .String (), Path : path }
217+ user : = User {UID : uid , Name : strings . Trim ( sessionUserName .String (), " \" " ), Path : path }
219218
220219 return & user , nil
221220}
222221
223222// GetSessionDisplay may be used to get the display for specific session
224223func (c * Conn ) GetSessionDisplay (sessionPath dbus.ObjectPath ) (string , error ) {
225224 if len (sessionPath ) == 0 {
226- return "" , fmt .Errorf ("Empty sessionPath" )
225+ return "" , fmt .Errorf ("empty sessionPath" )
227226 }
228227 sessionObj := c .conn .Object (dbusDest , sessionPath )
229228 display , err := sessionObj .GetProperty (dbusDest + ".Session.Display" )
230229 if err != nil {
231230 return "" , err
232231 }
233232
234- return display .String (), nil
233+ return strings . Trim ( display .String (), " \" " ), nil
235234}
236235
237236// GetSession may be used to get the session object path for the session with the specified ID.
0 commit comments